Trigger update of component view from service - No Provider for ChangeDetectorRef

后端 未结 6 843
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 01:22

I would like to udpate my application view, triggered by events from service.

One of my services injects the ChangeDetectorRef. Compilation works, but I am getting a

6条回答
  •  时光说笑
    2020-12-09 02:04

    You need to add your service to providers on component level:

    @Component({
      // ...
      providers: [MyService]
    })
    export class SomeComponent {
      // ...
    }
    

提交回复
热议问题