简体   繁体   中英

Angular 4, ngrx\store Plunker - TypeError: store_1.StoreModule.provideStore is not a function

I'm trying to create an Angular 4 plunker which includes ngrx\\store latest version: https://embed.plnkr.co/cr4rCJ0hRVMwuLzKe4mg/

In order to use ngrx\\store i've added this line in config.js file:

'@ngrx/store': 'https://npmcdn.com/@ngrx/store@4.0.0',

For some reason i'm getting this error:

(SystemJS) TypeError: store_1.StoreModule.provideStore is not a function

Can someone assist?

In the latest version of Ngrx the provideStore changed to forRoot .

Also you could have a look at the migration guide here https://github.com/ngrx/platform/blob/master/MIGRATION.md

You should change 'provideStore' to 'forRoot' in latest version of Angular like Angular 6. It worked for me.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule} from '@angular/forms';
import { UsersServiceService } from './users/users-service.service';
import { PDFGenerationService } from './pdf-generation-demo/pdf-generation.service';
import { AppRoutingModule, routingComponents } from './app-routing.module';
// Import ng-circle-progress
import { NgCircleProgressModule } from 'ng-circle-progress';
import { mainStoreReducer } from './state/reducers/reducer';
import { StoreModule } from '@ngrx/store';


@NgModule({
  declarations: [
    AppComponent,
    routingComponents
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    AppRoutingModule,
    NgCircleProgressModule.forRoot({
      // set defaults here
      radius: 100,
      outerStrokeWidth: 16,
      innerStrokeWidth: 8,
      outerStrokeColor: "#78C000",
      innerStrokeColor: "#C7E596",
      animationDuration: 300
    }),
    StoreModule.forRoot({ mainStoreReducer })
  ],
  exports: [   ],
  providers: [UsersServiceService, PDFGenerationService],
  bootstrap: [AppComponent]
})

export class AppModule { }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM