Home > Blockchain >  Angular 15 - View not updating after BehaviorSubject emmits change
Angular 15 - View not updating after BehaviorSubject emmits change

Time:12-18

I have a service with a BehaviourSubject which I can subscribe to from any component:

// getter in service
public get myObs$(): Observable<any> {
  return this._myBhvSub$.asObservable()
}

Then in the component I do

ngOnInit(): void {
  this.myService.myObs$.subscribe(res => {
    this.myVar = res
    console.log("My Var", this.myVar)
  })
}

concole.log() shows the data !! myVar is getting its value correctly !!

Finally HTML

<div>{{myVar.someKey}}</div>

This view just won't show the data

  • Related