Closed tavoli closed 6 years ago
it was the translate service I'm using, it does not work with this package since it needs HttpClient and it seems to me that this package changes the provider.
@gustalimame can you explain detail how you are fixed this issue. I am facing the same issue when I used the ngx-translate in my angular5 app
@gustalimame Use the passThruUnknowUrl
Otherwise, you can check example : https://github.com/angular/in-memory-web-api/tree/master/src/app
I approve @Davilink solution and wanted to share it also. Found it yesterday
I have a webpack error:
stack:
package.json
this service: `import { Injectable } from "@angular/core"; import { InMemoryDbService } from 'angular-in-memory-web-api';
@Injectable() export class InMemHeroService implements InMemoryDbService { createDb() { let heroes = [ {id: 1, name: 'Windstorm'}, {id: 2, name: 'Bombasto'}, {id: 3, name: 'Magneta'}, {id: 4, name: 'Tornado'} ]; return {heroes}; } }`
App module `import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { NgModule } from '@angular/core'; import { FormsModule } from "@angular/forms"; import { NgxPaginationModule } from "ngx-pagination"; import { HTTP_INTERCEPTORS, HttpClient, HttpClientModule } from "@angular/common/http"; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { MomentModule } from 'angular2-moment'; import { HttpClientInMemoryWebApiModule } from "angular-in-memory-web-api";
import { AppComponent } from './app.component'; import { AppRoutingModule } from "./app-routing.module"; import { ApiService, AuthInterceptor } from "./shared/service"; import { apiServiceFactory, httpLoaderFactory } from "./shared/factory"; import { NotFoundComponent } from './not-found/not-found.component'; import { ModalService } from "./shared/service"; import { InMemHeroService } from "./shared/service/inMemoryDataService";
@NgModule({ declarations: [ AppComponent, NotFoundComponent, ], imports: [ BrowserModule, BrowserAnimationsModule, NgxPaginationModule, FormsModule, HttpClientModule, HttpClientInMemoryWebApiModule.forRoot(InMemHeroService), AppRoutingModule, TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: httpLoaderFactory, deps: [HttpClient] } }), MomentModule, NgbModule, ], providers: [ { provide: ApiService, useFactory: apiServiceFactory, deps: [HttpClient] }, { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true, }, ModalService ], bootstrap: [AppComponent] }) export class AppModule { } `