Configuring your application

Once you have your reducers created, it’s time to configure your Angular application. In your main application module, simple add the StoreModule.provideStore() call to your @NgModule's imports:

app/app.module.ts

  1. import {BrowserModule} from '@angular/platform-browser';
  2. import {NgModule} from '@angular/core';
  3. import {FormsModule} from '@angular/forms';
  4. import {HttpModule} from '@angular/http';
  5. import {StoreModule} from '@ngrx/store';
  6. import {EffectsModule} from '@ngrx/effects';
  7. import 'rxjs/Rx';
  8. import {rootReducer} from './store/rootReducer';
  9. import {CounterActions} from './store/actions';
  10. import {CounterEffects} from './store/effects';
  11. import {AppComponent, CounterComponent} from './components';
  12. import {CounterService} from './services';
  13. @NgModule({
  14. imports: [
  15. BrowserModule,
  16. FormsModule,
  17. HttpModule,
  18. StoreModule.provideStore(rootReducer)
  19. ],
  20. declarations: [
  21. AppComponent,
  22. CounterComponent
  23. ],
  24. providers: [
  25. CounterActions,
  26. CounterService
  27. ],
  28. bootstrap: [AppComponent]
  29. })
  30. export class AppModule {
  31. }

原文: https://angular-2-training-book.rangle.io/handout/state-management/ngrx/configuring_your_application.html