Angular 无法识别 NgRX 操作
Angular NgRX action not recognized
我已经使用 NgRX 创建了 Angular 应用程序。我添加了动作、减速器、服务和效果。但是在访问操作时,组件代码出现以下错误。
Error: Property 'GetEmployees' does not exist on type 'typeof EmployeeAction'.
找到以下代码片段:
在 EmployeeComponent 中:
this.store.dispatch(new EmployeeAction.GetEmployees());
员工-actions.ts:
export class GetEmployees implements Action {
readonly type = GET_EMPLOYEES;
}
The entire App code will be available in this Github repository.
https://github.com/techvenky/AngularNgRx/tree/master/src
您导入抽象 class 并尝试创建其 属性 的实例。
GetEmployees
是一个class,导入再转。
所以,你的调度必须是这样的:
this.store.dispatch(new GetEmployees());
我还建议您从操作 classes.
的构造函数中的负载属性中删除 readonly
我已经使用 NgRX 创建了 Angular 应用程序。我添加了动作、减速器、服务和效果。但是在访问操作时,组件代码出现以下错误。
Error: Property 'GetEmployees' does not exist on type 'typeof EmployeeAction'.
找到以下代码片段:
在 EmployeeComponent 中:
this.store.dispatch(new EmployeeAction.GetEmployees());
员工-actions.ts:
export class GetEmployees implements Action {
readonly type = GET_EMPLOYEES;
}
The entire App code will be available in this Github repository.
https://github.com/techvenky/AngularNgRx/tree/master/src
您导入抽象 class 并尝试创建其 属性 的实例。
GetEmployees
是一个class,导入再转。
所以,你的调度必须是这样的:
this.store.dispatch(new GetEmployees());
我还建议您从操作 classes.
的构造函数中的负载属性中删除readonly