Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable angular2 in-memory-web-api for production

Tags:

angular

I'm using the angular2 in-memory-web-api for development. For the production environment I want to disable the in-memory-web-api and my real API to be used. Is there some way to disable the InMemoryWebApiModule for production?

like image 957
Emanuel Seidinger Avatar asked Oct 24 '16 08:10

Emanuel Seidinger


1 Answers

This simple approach works for me:

const ENV = 'prod'; // your global ENV variable;
-----

@NgModule({
  imports: [
    ...
    HttpModule,
    ENV !== 'prod' ? InMemoryWebApiModule.forRoot(DataMockService) : [],
  ],
  ...
})
export class AppModule {}
like image 131
Damsorian Avatar answered Oct 11 '22 05:10

Damsorian