【发布时间】:2016-10-28 11:49:07
【问题描述】:
我一直在使用加载组件来在内容被调用和从 API 加载之间进行友好的等待。只是文本时没有问题,但是当信息有图像或更多信息时,加载组件在内容完全加载之前消失。
我查看了 Angular2 的生命周期挂钩,但其中任何一个看起来都符合我的要求。
主要是我的组件了解 isLoading = true 何时必须消失。
这是我尝试做的方式。
ngOnInit() {
// Payload to call the API
var model: myPayload = {
AuthorId: this._authorid,
CountryId: this._countryid
}
// Api loading
Observable.forkJoin(
this._service.getList(model)
)
.subscribe(
res => {
this.authorList = res[0];
},
null,
() => {
this.isLoading = false
}
)
}
【问题讨论】:
标签: angular angular2-template angular2-directives angular2-components