Hivaga
Hivaga

Reputation: 4536

Get reference to injector inside Angular 2.X custom module?

How we can get a reference to dependency injector inside the application module ?

Here is the example code of the custom module. So how we can get reference to Angular DI (Dependency Injector) inside this class ?

@NgModule({
  declarations: [
    MyApplication,
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [MyApplication]
})
export class MyApplicationModule {
  constructor() {

  }

}

Upvotes: 3

Views: 1089

Answers (1)

user4676340
user4676340

Reputation:

You mean this ?

export class MyApplicationModule {
  constructor(private injector: Injector) {}
}

Upvotes: 4

Related Questions