简体   繁体   中英

how to get the async pipe working with rxjs

I need help, since the else loading of my async pipe does not trigger, even though the data load works correctly, the loading template never triggers when subscribing, I have a BehaviorSubject in my service. If anyone help me with any solution I would appreciate it too much as I have tried a lot of things and could not reach the expected result. My expected result is that when choosing a date, it triggers the subscription and while it subscribes the loading is triggered, if the length is greater than 0 the table is loaded, if not, it shows the template that there are no items. Thank you very much in advance. 在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

BehaviourSubject() is an observable, so you will need to subscribe to your data source before setting your subject to the result of your observable. Without a subscription there will be no result!

Try the following in your test (if list is an observable in your api service):

this.apiAgenda().list.subscribe(res => 
{
  this.list$.next(res); 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM