If you want the properties in the component to be updated as soon as the change value in the service changes:
- Import
DoCheck from @angular/core and your service into the component. - Call service functions that affect the component property in
ngDoCheck(){...} - The component view is automatically updated immediately after any changes.
Something like this in your component:
ngDoCheck() { this.qty = this.cartService.getTotalQtyInCart(); }
source share