我尝试显示项目列表(分页)的一部分。 我的模板:显示地图后可观察
<div class="notif" *ngFor="let notif of paginate() | async">
{{notif.name}}
</div>
在我的组件,如果我做的:
public notifications: Observable<Notification[]>;
public paginate(): Observable<Notification[]> {
return this.notifications;
}
这是工作,但如果我这样做:
public notifications: Observable<Notification[]>;
public paginate(): Observable<Notification[]> {
return this.notifications.map((notif: Notification[]) => {
return notif;
});
它不工作了(I”已经简化了功能以理解发生了什么)。 .map回收一个可观察的权利?所以它应该两种方式工作?
yap!它应该同时工作,可能做了一些愚蠢的错误,并且可观察部分看起来不错 –
你得到的错误/行为是什么? –
在第一种情况下,我看到通知名称,在第二种情况下,什么也没有发生,页面上没有显示 – Lempkin