How to change value of a variable in service and reflect it in a component that uses that service

Solution 1:

Please try to create BehaviorSubject variable in service, e.g. serviceStatus = new BehaviourSubject(false); // default value is false and in the takeAction method change value of serviceStatus variable to true, e.g. this.serviceStatus.next(true);

In your app.component.ts in ngOnInit subscribe to serviceStatus variable, e.g. this._myService.serviceStatus.pipe(takeUntil(this.destroy$)).subscribe(data => this.status = data); // takeUntil is for unsubscribing when component is destroyed - protect from memory leak