angular - Calling function 'InMemoryWebApiModule', function calls are not supported in angular2 -


i making angular2 tutorial cli.

when made http service(tutorial step 7), discovered 1 issue.

after try ng serve:

calling function 'inmomorywebapimodule', function calls not supported. webpack: failed compile. 

main.ts:

import { platformbrowserdynamic }           '@angular/platform-browser-dynamic'; import { enableprodmode }                   '@angular/core'; import { environment }                      './environments/environment'; import { appmodule }                        './app/app.module'; import{inmemorybackendservice, seed_data }  'angular2-in-memory-web-api'  if (environment.production) {   enableprodmode(); }  platformbrowserdynamic().bootstrapmodule(appmodule); 

app.module.ts:

import { ngmodule }      '@angular/core'; import { browsermodule } '@angular/platform-browser'; import { formsmodule }   '@angular/forms'; import { httpmodule }    '@angular/http';  import { approutingmodule }     './app-routing.module';  // imports loading & configuring in-memory web api import { inmemorywebapimodule } 'angular2-in-memory-web-api'; import { inmemorydataservice }  './in-memory-data.service';  import { appcomponent }        './app.component'; import { dashboardcomponent }  './dashboard.component'; import { herodetailcomponent } './hero-detail.component'; import { heroescomponent }     './heroes.component'; import { heroservice }         './hero.service'; import { herosearchcomponent } './hero-search.component';  @ngmodule({   imports: [     browsermodule,     formsmodule,     httpmodule,     inmemorywebapimodule.forroot(inmemorydataservice),     approutingmodule   ],   declarations: [     appcomponent,     dashboardcomponent,     herodetailcomponent,     heroescomponent,     herosearchcomponent   ],   providers: [heroservice],   bootstrap: [appcomponent] })  export class appmodule { } 

in-memory-data.service.ts:

import { inmemorydbservice } 'angular2-in-memory-web-api'; export class inmemorydataservice implements inmemorydbservice {   createdb() {     let heroes = [       {id: 11, name: 'mr. nice'},       {id: 12, name: 'narco'},       {id: 13, name: 'bombasto'},       {id: 14, name: 'celeritas'},       {id: 15, name: 'magneta'},       {id: 16, name: 'rubberman'},       {id: 17, name: 'dynama'},       {id: 18, name: 'dr iq'},       {id: 19, name: 'magma'},       {id: 20, name: 'tornado'}     ];     return {heroes};   } } 

enter image description here

you seem using old version of https://github.com/angular/in-memory-web-api.

install npm install --save angular-in-memory-web-api instead (without 2), version should ok. old version wasn't statically analyzable caused problems aot.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -