【发布时间】:2018-06-05 23:37:15
【问题描述】:
如果我有一个组件并想显示一个加载器
组件
ngOnInit() {
this.route.params
.do(x => this.contentLoading = true)
.switchMap(x => this.getClientSearchResults())
.subscribe(x => {
this.clientSearchResults = x;
this.contentLoading = false
});
}
模板
<mat-progress-spinner *ngIf="contentLoading" color="accent" mode="indeterminate"></mat-progress-spinner>
加载器将在页面第一次加载时显示,但是对参数的任何更改都将不再显示加载器。我可以看到 Observable 链每次都以console.log 运行。 ngZone 在运行 Observable 链时是否检测不到它?
【问题讨论】:
标签: javascript angular angular5 observable