Angular 7 Component Inheritance using a global injector

前端 未结 1 1763
旧巷少年郎
旧巷少年郎 2021-01-03 07:32

I\'ve been using the approach described in an MSDN blog post to simplify extending components without needing to provide all the dependencies in the super() cal

相关标签:
1条回答
  • 2021-01-03 07:45

    I have set the injector service in AppModule and that mean I will inject Injector and set it in the constractor of AppModule and store the injector service in global object

    export class AppModule { 
      constructor(injector:Injector){
      // Store module's injector in the AppInjector class
      console.log('Expected #1: storing app injector');
      AppInjector.setInjector(injector);
      }
    }
    

    demo

    0 讨论(0)
提交回复
热议问题