我们如何在应用程序模块中获取对依赖注入器的引用?
以下是自定义模块的示例代码。那么我们如何在这个类中引用Angular DI(Dependency Injector)?
@NgModule({
declarations: [
MyApplication,
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
bootstrap: [MyApplication]
})
export class MyApplicationModule {
constructor() {
}
}
答案 0 :(得分:2)
export class MyApplicationModule {
constructor(private injector: Injector) {}
}