Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: No provider for Store! when trying @ngrx/store with Angular 4.0

Problem: Error: No provider for Store!

I'm bootstraping store module in main.ts:

platformBrowserDynamic().bootstrapModule(AppModule,[
  provideStore({
    characters, 
    vehicles
  })
]);

And injecting in to vehicle.component.ts:

constructor(
    private _route: ActivatedRoute,
    private _router: Router,
    private _vehicleService: VehicleService,
    private _store: Store<any>
  ) {}

Full source code is here: GitHub, last version running on GitHub Pages

PS. Adding Store to providers leads to another error: Can't resolve all parameters for Store: (?, ?, ?).

like image 261
Anton Pegov Avatar asked May 30 '17 16:05

Anton Pegov


People also ask

Where is NgRx store stored?

Where Does NgRx Store Data? NgRx stores the application state in an RxJS observable inside an Angular service called Store. At the same time, this service implements the Observable interface.

How do I reset my NgRx?

store. dispatch(logout()); In effects, dispatch logout success action so that the user logs out and the store is reset.


1 Answers

I had this error because, in my component auto-import imported Store from import { Store } from '@ngrx/store/src/store' instead of import { Store } from '@ngrx/store'; . Anyway, this was in Angular 5

like image 193
Alf Moh Avatar answered Nov 10 '22 00:11

Alf Moh