InMemoryWebApiModule does not work.
See original GitHub issuenpm install --save angular2-in-memory-web-api then do like the tutorial
step 1 add in-memory-data.service.ts //in-memory-data.service.ts
import {InMemoryDbService} from "angular2-in-memory-web-api/index";
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};
}
}
step2 update AppModule //app.module.ts
import {BrowserModule, Title} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {AppComponent} from "./app.component";
import {AppRoutingModule} from "./app-routing.module";
import {PageNotFoundComponent} from "./common/page-not-found/page-not-found.component";
import {InMemoryWebApiModule} from "angular2-in-memory-web-api/index";
import {InMemoryDataService} from "./memory-data/in-memory-data.service";
@NgModule({
declarations: [
AppComponent,
PageNotFoundComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
InMemoryWebApiModule.forRoot(InMemoryDataService),
AppRoutingModule
],
providers: [
Title
],
bootstrap: [AppComponent]
})
export class AppModule { }
After done the steps above,I just run start
script in package.json(ng serve)
Output an error:
ERROR in Error encountered resolving symbol values statically. Calling function ‘InMemoryWebApiModule’, function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in D:/angular2/cli-demo/src/app/app.module.ts, resolving symbol AppModule in D:/angular2/cli-demo/src/app/app.module.ts
What’s wrong?How could I make it works?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:20 (1 by maintainers)
Top Results From Across the Web
angular-in-memory-web-api not responding - Stack Overflow
No run time error in the js console. Nothing is happening. Like if there was no response from the "api server". I even...
Read more >How to use the angular-in-memory-web-api/in-memory ... - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >Angular 15 In-memory Web API tutorial: Mocking CRUD APIs ...
This is really handy for Angular developers who are working on a front-end application but do not yet have a back-end in place....
Read more >Angular In-memory Web API tutorial: Mocking CRUD APIs in ...
A tutorial of Angular's in-memory-web-api to make a simple CRUD server, and to create a functional frontend without backend assistance.
Read more >angular-in-memory-web-api - npm
If an existing, running remote server should handle requests for collections that are not in the in-memory database, set Config.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Faced version compatibility issues:
According to changelog: https://github.com/angular/in-memory-web-api/blob/master/CHANGELOG.md Version 0.6.0 has breaking changes and is probably only compatible with Angular 6 (not LTS yet).
Made it work by downgrading to angular-in-memory-web-api@0.5.4.
npm install angular-in-memory-web-api@0.5.4 --save
encountered the same problem, with angular-in-memory-web-api: 0.5.3 @angular/cli 1.6.7