3
我想要一个替代角1中的$ http.pendingRequest或任何东西跟踪全局像拦截器。主要用于展示,而调用已取得如何跟踪角2中的挂起的HTTP请求
我想要一个替代角1中的$ http.pendingRequest或任何东西跟踪全局像拦截器。主要用于展示,而调用已取得如何跟踪角2中的挂起的HTTP请求
加载图标你可以做这样的事情:
getItem(itemID:string){
if(this.pendingRequest){
this.pendingRequest.unsubscribe();
}
this.pendingRequest = this.http.get(`./country-info/${itemID}`).map((res: Response) => res.json()).subscribe(res => this.item = res.item);
}
我可能只是维持图标的状态,而观察到的至今未归。
实施例:
export class MyClass {
private isLoaded = false;
constructor(private myService: MyService){}
ngOnInit(){
this.myService.myServiceCall().subscribe(data => {
console.log(data);
this.isLoaded = true;
});
}
}
然后对话框上使用*ngIf
。您还可以考虑使用Angular为这种场景提供的异步管道:
https://angular.io/docs/ts/latest/api/common/index/AsyncPipe-pipe.html