2
在測試版,我可以這樣做:如何使用運行時數據在Angular 2中註冊提供者?
export class AppBootstrapper {
constructor(mySettings: AppSettings) {
bootstrap(App,
[
provide(AppSettings, {
useFactory:() => mySettings
})
]
}
}
}
藉助於此「mySettings」是從服務器運行時的數據。
我該如何在最新的RC中做到這一點?
export class AppBootstrapper {
constructor(mySettings: AppSettings) {
platform.bootstrapModule(AppModule);
}
}
我能不能把它引導,但不能進入app.module.ts
providers: [
{ provide: AppSettings, useFactory: => new AppSettings(??) }
]
,
你可以嘗試像[這](http://stackoverflow.com/a/39454713/2587435) –