RxJs get value from observable

前端 未结 3 1717
盖世英雄少女心
盖世英雄少女心 2020-12-06 03:58

In component :

singleEvent$: Observable;

On init, I get observable

this.singleEvent$ = this._eventService.even         


        
3条回答
  •  渐次进展
    2020-12-06 04:30

    To get data from an observable, you need to subscribe:

    this.singleEvents$.subscribe(event => this.event = event);
    

    In the template you can directly bind to observables using the async pipe:

    {{singleEvents$ | async}}
    

提交回复
热议问题