From c392eeae676fc23069455b0a4a410adc25add6db Mon Sep 17 00:00:00 2001 From: David Ellams Date: Wed, 13 Feb 2019 12:40:55 +0800 Subject: [PATCH] STEP 06 WIP --- package-lock.json | 5 +++++ package.json | 1 + src/app/app.module.ts | 12 +++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 0bb7fe5..a2e7363 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1098,6 +1098,11 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, + "angular-in-memory-web-api": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/angular-in-memory-web-api/-/angular-in-memory-web-api-0.8.0.tgz", + "integrity": "sha512-2n0YtCLFxZo4JePHvH6q8b7JmBmhZq44Ic8VaBPRSXE4vAmlKXHU+kI2quNa612EAETDRkZcvLOU8K8CkhIZgQ==" + }, "ansi-colors": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", diff --git a/package.json b/package.json index 58f1ba8..5bf9b16 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@angular/platform-browser": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", + "angular-in-memory-web-api": "^0.8.0", "core-js": "^2.5.4", "rxjs": "~6.3.3", "tslib": "^1.9.0", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b18a27a..f23c6a2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -2,6 +2,9 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; // <-- NgModel lives here import { AppRoutingModule } from './app-routing.module'; +import { HttpClientModule } from '@angular/common/http'; +import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api'; +import { InMemoryDataService } from './in-memory-data.service'; import { AppComponent } from './app.component'; import { HeroesComponent } from './heroes/heroes.component'; @@ -22,7 +25,14 @@ import { DashboardComponent } from './dashboard/dashboard.component'; imports: [ BrowserModule, FormsModule, - AppRoutingModule + AppRoutingModule, + HttpClientModule, + + // The HttpClientInMemoryWebApiModule module intercepts HTTP requests + // and returns simulated server responses. + // Remove it when a real server is ready to receive requests. + HttpClientInMemoryWebApiModule.forRoot( + InMemoryDataService, { dataEncapsulation: false }) ], providers: [], bootstrap: [AppComponent]