3

What is the best way to listen to a variable change in Anuglar2 service. And on this change the component updates itself.

Ajey
  • 7,924
  • 12
  • 62
  • 86
  • Use an Observable. – JB Nizet Aug 22 '16 at 06:04
  • To be more exact, use `Subject` to store variable's value. `Subject` is an `Observable` anyway, so you can `subscribe` to it in the component to update your view when needed. – Harry Ninh Aug 22 '16 at 06:18
  • 2
    See https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service – Günter Zöchbauer Aug 22 '16 at 06:39
  • Does this answer your question? [listen to service variable change from component angular](https://stackoverflow.com/questions/55259419/listen-to-service-variable-change-from-component-angular) – canbax Dec 11 '19 at 11:22

0 Answers0