Reputation: 1878
I want my page to dispatch an action on the ngOnInit
, this action will be catch by an effect and the effect will this.router.navigate(['path'])
to a new path.
I don't need any reducer here.
But I cannot manage to make it work since this.store.dispatch()
will only work if I inject my store as a DI and type it as my current state like so private store: State<fromReducers.State>
My module as imported the store like so :
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([
{ path: '', pathMatch: 'full', component: EvaluationContainer }
]),
StoreModule.forFeature('evaluation', {}),
EffectsModule.forFeature(Effects)
],
declarations: [EvaluationContainer]
})
export class FeatureEvaluationModule {}
How can I still dispatch the action in this situation?
Thanks!
Upvotes: 1
Views: 739
Reputation: 13574
you need to import StoreModule.forRoot()
in the parent module. If it is your root module, then here. The StoreModule.forFeature('evaluation', {})
part you can skip here.
That's how I do the same: https://take.ms/ZXxOx
Upvotes: 0