chore: update samples to "angular-in-memory-web-api" (#2472)
chore: update samples to "angular-in-memory-web-api"
This commit is contained in:
parent
738b714bd3
commit
6e17d33475
@ -9,7 +9,7 @@ import { LocationStrategy,
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { HeroData } from './hero-data';
|
import { HeroData } from './hero-data';
|
||||||
import { InMemoryWebApiModule } from 'angular2-in-memory-web-api';
|
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
|
||||||
|
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
"@angular/platform-server": "2.0.0",
|
"@angular/platform-server": "2.0.0",
|
||||||
"@angular/router": "3.0.0",
|
"@angular/router": "3.0.0",
|
||||||
"@angular/upgrade": "2.0.0",
|
"@angular/upgrade": "2.0.0",
|
||||||
"angular2-in-memory-web-api": "0.0.20",
|
"angular-in-memory-web-api": "0.1.0",
|
||||||
"bootstrap": "^3.3.6",
|
"bootstrap": "^3.3.6",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"reflect-metadata": "^0.1.3",
|
"reflect-metadata": "^0.1.3",
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
|
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
|
||||||
|
|
||||||
// other libraries
|
// other libraries
|
||||||
'rxjs': 'npm:rxjs',
|
'rxjs': 'npm:rxjs',
|
||||||
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
|
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
|
||||||
},
|
},
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
// packages tells the System loader how to load when no filename and/or no extension
|
||||||
packages: {
|
packages: {
|
||||||
@ -37,7 +37,7 @@
|
|||||||
rxjs: {
|
rxjs: {
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
},
|
},
|
||||||
'angular2-in-memory-web-api': {
|
'angular-in-memory-web-api': {
|
||||||
main: './index.js',
|
main: './index.js',
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { BrowserModule } from '@angular/platform-browser';
|
|||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { HttpModule, JsonpModule } from '@angular/http';
|
import { HttpModule, JsonpModule } from '@angular/http';
|
||||||
|
|
||||||
import { InMemoryWebApiModule } from 'angular2-in-memory-web-api';
|
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
|
||||||
import { HeroData } from './hero-data';
|
import { HeroData } from './hero-data';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// #docregion
|
// #docregion
|
||||||
import { InMemoryDbService } from 'angular2-in-memory-web-api';
|
import { InMemoryDbService } from 'angular-in-memory-web-api';
|
||||||
export class HeroData implements InMemoryDbService {
|
export class HeroData implements InMemoryDbService {
|
||||||
createDb() {
|
createDb() {
|
||||||
let heroes = [
|
let heroes = [
|
||||||
|
@ -15,14 +15,14 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HeroService {
|
export class HeroService {
|
||||||
// #docregion ctor
|
|
||||||
constructor (private http: Http) {}
|
|
||||||
// #enddocregion ctor
|
|
||||||
|
|
||||||
// #docregion endpoint
|
// #docregion endpoint
|
||||||
private heroesUrl = 'app/heroes'; // URL to web API
|
private heroesUrl = 'app/heroes'; // URL to web API
|
||||||
// #enddocregion endpoint
|
// #enddocregion endpoint
|
||||||
|
|
||||||
|
// #docregion ctor
|
||||||
|
constructor (private http: Http) {}
|
||||||
|
// #enddocregion ctor
|
||||||
|
|
||||||
// #docregion methods, error-handling, http-get
|
// #docregion methods, error-handling, http-get
|
||||||
getHeroes (): Observable<Hero[]> {
|
getHeroes (): Observable<Hero[]> {
|
||||||
return this.http.get(this.heroesUrl)
|
return this.http.get(this.heroesUrl)
|
||||||
|
@ -3,7 +3,7 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { HttpModule } from '@angular/http';
|
import { HttpModule } from '@angular/http';
|
||||||
import { InMemoryWebApiModule } from 'angular2-in-memory-web-api';
|
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
|
||||||
|
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
|
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
|
||||||
|
|
||||||
// other libraries
|
// other libraries
|
||||||
'rxjs': 'npm:rxjs',
|
'rxjs': 'npm:rxjs',
|
||||||
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
|
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
|
||||||
},
|
},
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
// packages tells the System loader how to load when no filename and/or no extension
|
||||||
packages: {
|
packages: {
|
||||||
@ -37,7 +37,7 @@
|
|||||||
rxjs: {
|
rxjs: {
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
},
|
},
|
||||||
'angular2-in-memory-web-api': {
|
'angular-in-memory-web-api': {
|
||||||
main: './index.js',
|
main: './index.js',
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@
|
|||||||
'@angular/forms/testing': 'ng:forms-builds/master/bundles/forms-testing.umd.js',
|
'@angular/forms/testing': 'ng:forms-builds/master/bundles/forms-testing.umd.js',
|
||||||
|
|
||||||
// other libraries
|
// other libraries
|
||||||
'rxjs': 'npm:rxjs',
|
'rxjs': 'npm:rxjs',
|
||||||
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
|
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
|
||||||
'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js',
|
'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js',
|
||||||
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
|
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
|
||||||
|
|
||||||
},
|
},
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
// packages tells the System loader how to load when no filename and/or no extension
|
||||||
@ -65,7 +65,7 @@
|
|||||||
rxjs: {
|
rxjs: {
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
},
|
},
|
||||||
'angular2-in-memory-web-api': {
|
'angular-in-memory-web-api': {
|
||||||
main: './index.js',
|
main: './index.js',
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,10 @@
|
|||||||
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
|
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
|
||||||
|
|
||||||
// other libraries
|
// other libraries
|
||||||
'rxjs': 'npm:rxjs',
|
'rxjs': 'npm:rxjs',
|
||||||
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
|
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
|
||||||
'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js',
|
'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js',
|
||||||
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
|
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
|
||||||
|
|
||||||
},
|
},
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
// packages tells the System loader how to load when no filename and/or no extension
|
||||||
@ -52,7 +52,7 @@
|
|||||||
rxjs: {
|
rxjs: {
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
},
|
},
|
||||||
'angular2-in-memory-web-api': {
|
'angular-in-memory-web-api': {
|
||||||
main: './index.js',
|
main: './index.js',
|
||||||
defaultExtension: 'js'
|
defaultExtension: 'js'
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import { HttpModule } from '@angular/http';
|
|||||||
|
|
||||||
// #enddocregion v1
|
// #enddocregion v1
|
||||||
// Imports for loading & configuring the in-memory web api
|
// Imports for loading & configuring the in-memory web api
|
||||||
import { InMemoryWebApiModule } from 'angular2-in-memory-web-api';
|
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
|
||||||
import { InMemoryDataService } from './in-memory-data.service';
|
import { InMemoryDataService } from './in-memory-data.service';
|
||||||
|
|
||||||
// #docregion v1
|
// #docregion v1
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// #docregion , init
|
// #docregion , init
|
||||||
import { InMemoryDbService } from 'angular2-in-memory-web-api';
|
import { InMemoryDbService } from 'angular-in-memory-web-api';
|
||||||
export class InMemoryDataService implements InMemoryDbService {
|
export class InMemoryDataService implements InMemoryDbService {
|
||||||
createDb() {
|
createDb() {
|
||||||
let heroes = [
|
let heroes = [
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
// map tells the System loader where to look for things
|
// map tells the System loader where to look for things
|
||||||
// #docregion paths
|
// #docregion paths
|
||||||
var map = {
|
var map = {
|
||||||
'app': '/app', // 'dist',
|
'app': '/app', // 'dist',
|
||||||
|
|
||||||
'@angular': '/node_modules/@angular',
|
'@angular': '/node_modules/@angular',
|
||||||
'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
|
'angular-in-memory-web-api': '/node_modules/angular-in-memory-web-api',
|
||||||
'rxjs': '/node_modules/rxjs'
|
'rxjs': '/node_modules/rxjs'
|
||||||
};
|
};
|
||||||
|
|
||||||
var packages = {
|
var packages = {
|
||||||
'/app': { main: 'main.js', defaultExtension: 'js' },
|
'/app': { main: 'main.js', defaultExtension: 'js' },
|
||||||
'rxjs': { defaultExtension: 'js' },
|
'rxjs': { defaultExtension: 'js' },
|
||||||
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
|
'angular-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
|
||||||
};
|
};
|
||||||
// #enddocregion paths
|
// #enddocregion paths
|
||||||
|
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
// map tells the System loader where to look for things
|
// map tells the System loader where to look for things
|
||||||
// #docregion paths
|
// #docregion paths
|
||||||
var map = {
|
var map = {
|
||||||
'app': '/app', // 'dist',
|
'app': '/app', // 'dist',
|
||||||
|
|
||||||
'@angular': '/node_modules/@angular',
|
'@angular': '/node_modules/@angular',
|
||||||
'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
|
'angular-in-memory-web-api': '/node_modules/angular-in-memory-web-api',
|
||||||
'rxjs': '/node_modules/rxjs'
|
'rxjs': '/node_modules/rxjs'
|
||||||
};
|
};
|
||||||
|
|
||||||
var packages = {
|
var packages = {
|
||||||
'/app': { main: 'main.js', defaultExtension: 'js' },
|
'/app': { main: 'main.js', defaultExtension: 'js' },
|
||||||
'rxjs': { defaultExtension: 'js' },
|
'rxjs': { defaultExtension: 'js' },
|
||||||
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
|
'angular-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
|
||||||
};
|
};
|
||||||
// #enddocregion paths
|
// #enddocregion paths
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ a#in-mem-web-api
|
|||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
The in-memory web api is not part of the Angular core.
|
The in-memory web api is not part of the Angular core.
|
||||||
It's an optional service in its own `angular2-in-memory-web-api` library
|
It's an optional service in its own `angular-in-memory-web-api` library
|
||||||
that we installed with npm (see `package.json`) and
|
that we installed with npm (see `package.json`) and
|
||||||
registered for module loading by SystemJS (see `systemjs.config.js`)
|
registered for module loading by SystemJS (see `systemjs.config.js`)
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ a(id="other")
|
|||||||
:marked
|
:marked
|
||||||
### Other helper libraries
|
### Other helper libraries
|
||||||
|
|
||||||
***angular2-in-memory-web-api*** - An Angular-supported library that simulates a remote server's web api
|
***angular-in-memory-web-api*** - An Angular-supported library that simulates a remote server's web api
|
||||||
without requiring an actual server or real http calls.
|
without requiring an actual server or real http calls.
|
||||||
Good for demos, samples, and early stage development (before we even have a server).
|
Good for demos, samples, and early stage development (before we even have a server).
|
||||||
Read about it in the [Http Client](server-communication.html#appendix-tour-of-heroes-in-memory-server) page.
|
Read about it in the [Http Client](server-communication.html#appendix-tour-of-heroes-in-memory-server) page.
|
||||||
|
@ -654,7 +654,7 @@ a#in-mem-web-api
|
|||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
The in-memory web api is not part of the Angular core.
|
The in-memory web api is not part of the Angular core.
|
||||||
It's an optional service in its own `angular2-in-memory-web-api` library
|
It's an optional service in its own `angular-in-memory-web-api` library
|
||||||
that we installed with npm (see `package.json`) and
|
that we installed with npm (see `package.json`) and
|
||||||
registered for module loading by SystemJS (see `systemjs.config.js`)
|
registered for module loading by SystemJS (see `systemjs.config.js`)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user