【发布时间】:2018-06-03 06:05:54
【问题描述】:
我有一个角度分量 使用这样的构造函数:
newTrips$: Observable<Trip[]>;
constructor(private store: Store<fromRoot.State>, private tripFeedService: TripFeedService) {
this.newTrips$ = store.select(fromRoot.getTripFeedUnreadTrips);
this.newTrips$.subscribe(x => { console.log('subscribe'); console.log(x); });
}
在我看来是这样的:
<div *ngFor="let trip of newTrips$ | async">test</div>
问题是如果页面加载时 Trip[] 为空。视图中的 ngfor 永远不会被调用。我的控制台确实显示了显示“订阅”的日志消息和列表中的对象。如果刷新页面,项目就会显示出来,并且 observable 的所有后续更改都会正确显示在控制台和 ui 中
【问题讨论】:
标签: angular