码迷,mamicode.com
首页 > 其他好文 > 详细

angular5.x全局loading解决方法

时间:2019-01-28 21:17:56      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:ons   while   vat   star   outer   lse   port   als   angular   

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解决方法

标签:ons   while   vat   star   outer   lse   port   als   angular   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!