【发布时间】:2017-01-04 07:05:23
【问题描述】:
我正在为两个 json 服务(DB)使用 In memory web api
1)
import {InMemoryDbService} from 'angular-in-memory-web-api';
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};
}
}
2)
import {InMemoryDbService} from 'angular-in-memory-web-api';
import {Address} from "cluster";
export class StudentData implements InMemoryDbService {
createDb() {
let students = [
{
id: 11,
FirstName: 'Mounika',
LastName: 'Gangamwar',
email: 'asa@gmailc.com',
Phonenumber: 1111,
Address: '2323',
Password: 'asa',
CPassword: 'aa'
}
];
return {students};
}
}
我的 app.module.js 是
import {InMemoryWebApiModule} from 'angular-in-memory-web-api';
import {InMemoryDataService} from './in-memory-data.service';
import {StudentData} from './forms/student.data.service';
@
NgModule({
imports: [
BrowserModule,
FormsModule,
InMemoryWebApiModule.forRoot(InMemoryDataService, StudentData)
],
declarations: [AppComponent],
bootstrap: [UIView]
})
我的问题是我无法在InMemoryWebApiModule.forRoot(InMemoryDataService,StudentData)] 中添加两个数据库
StudentData 服务出现 404 错误。如果我从中删除一个 dbService 工作正常
我的疑惑是如何在forRoot方法中添加两个dbservices?
【问题讨论】:
-
您找到解决方案了吗?我手上也有同样的问题。
-
解决方案已经可用并在其 repo (github.com/angular/in-memory-web-api/issues/68) 中关闭
标签: angular angular2-routing angular2-template angular2-services