Search code examples
angularngrxngrx-storengrx-effects

Angular NgRX action not recognized


I have created Angular application using NgRX. I have added actions, reducers, services and effects. But while access the action got the below error in component code.

Error: Property 'GetEmployees' does not exist on type 'typeof EmployeeAction'.

find the below code snippets:

In EmployeeComponent:

this.store.dispatch(new EmployeeAction.GetEmployees());

employee-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

Solution

  • you import abstract class and try to create instance of its property. GetEmployees it is a class, import it and turn to it. So, your dispatch must be like this: this.store.dispatch(new GetEmployees());

    And also I recommend you to remove readonly from payload properties in constructors of action classes.