2
我正在使用的內存的Web API兩個JSON服務(DB)如何在存儲網絡API爲兩種不同的jsons
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: '[email protected]',
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)]
我得到404錯誤爲學生數據服務。如果我從它的工作正常刪除一個dbService
我的疑問是如何將兩個dbservices添加到forRoot方法?
你已經找到了解決方案只是返回兩個集合?我手中也有同樣的問題。 – John