I have a component which has a method interval(), when a button is clicked.
 interval() {
    this.statusInterval = interval(2000).subscribe(x => {
      this.interval2 = x;
      console.log(this.interval2);
      this.assetItemActionService.sendNumber(x);
    })
  }
In constructor I have this subscription which should update that value.
 interval2 = 0;
 percentSubscription= Subscription;
  constructor(private service:Service) {
    console.log('takeee');
    this.percentSubscription = this.service.number$.subscribe(percent => {
      console.log("set number");
      this.interval2 = percent;
    }, error => console.log(error))
  }
The up 2 code fragments are in the same component.
In service I have this subject which is updated constantly.
private number: Subject<number> = new Subject();
number$ = this.number.asObservable();
  sendNumber(number) {
    console.log('received');
    this.number.next(number);
  }
The problem is when I route to another page, the UI is not updated, and the part from constructor is not working anymore, I can't subscribe, but in console the value is updated every time. So the UI is not rendered, and I can't subscribe anymore to that subject after I come back on component.
How I can solve this?
 
     
    