首页 > 其他 > 详细

angular5.x全局loading解决方法

时间:2019-01-28 20:36:26      阅读:549      评论:0      收藏:0      [点我收藏+]
import { Router, ActivatedRoute, NavigationEnd, NavigationStart } from ‘@angular/router‘;
private allLoading: boolean = false;
 
constructor(
private router: Router,
private activatedRoute: ActivatedRoute
) {
setTimeout(() => {
this.routerChange();
});
}
public routerChange() {
this.router.events
.filter(event => event instanceof NavigationStart)
.map(() => this.activatedRoute)
.map((route: any) => {
while (route.firstChild) route = route.firstChild;
return route;
})
.subscribe((event) => {
this.allLoading = true;
this.router.events
.filter(event => event instanceof NavigationEnd)
.map(() => this.activatedRoute)
.map((route: any) => {
while (route.firstChild) route = route.firstChild;
return route;
})
.subscribe((event) => {
this.allLoading = false;
});
});
}

angular5.x全局loading解决方法

原文:https://www.cnblogs.com/aisiqi-love/p/10331603.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!