@angular/router#RouteConfigLoadEnd TypeScript Examples
The following examples show how to use
@angular/router#RouteConfigLoadEnd.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: top-progress-bar.component.ts From ng-ant-admin with MIT License | 6 votes |
constructor(private router: Router, private cdr: ChangeDetectorRef) {
this.router.events.subscribe(evt => {
// 表示在惰性加载某个路由配置前触发的事件。
if (!this.isFetching && evt instanceof RouteConfigLoadStart) {
this.isFetching = true;
this.cdr.markForCheck();
}
if (!this.isFetching && evt instanceof NavigationStart) {
this.isFetching = true;
this.cdr.markForCheck();
}
if (evt instanceof NavigationError || evt instanceof NavigationCancel) {
this.isFetching = false;
if (evt instanceof NavigationError) {
}
this.cdr.markForCheck();
return;
}
if (!(evt instanceof NavigationEnd || evt instanceof RouteConfigLoadEnd)) {
return;
}
if (this.isFetching) {
setTimeout(() => {
this.isFetching = false;
this.cdr.markForCheck();
}, 600);
}
});
}
Example #2
Source File: app.component.ts From open-genes-frontend with Mozilla Public License 2.0 | 6 votes |
private handleRouterState(): void {
this.router.events.pipe(takeUntil(this.subscription$)).subscribe((event: RouterEvent) => {
if (event instanceof NavigationEnd || event instanceof RouteConfigLoadEnd) {
// Hide progress spinner or progress bar
this.currentRoute = event.url;
if (this.currentRoute === '/404') {
this.isFooterVisible = false;
}
setTimeout(() => {
this.document.body.classList.remove('body--loading');
}, 2000);
}
});
}
Example #3
Source File: admin-layout.component.ts From matx-angular with MIT License | 6 votes |
ngOnInit() {
// this.layoutConf = this.layout.layoutConf;
this.layoutConfSub = this.layout.layoutConf$.subscribe((layoutConf) => {
this.layoutConf = layoutConf;
// console.log(this.layoutConf);
this.adminContainerClasses = this.updateAdminContainerClasses(this.layoutConf);
this.cdr.markForCheck();
});
// FOR MODULE LOADER FLAG
this.moduleLoaderSub = this.router.events.subscribe(event => {
if(event instanceof RouteConfigLoadStart || event instanceof ResolveStart) {
this.isModuleLoading = true;
}
if(event instanceof RouteConfigLoadEnd || event instanceof ResolveEnd) {
this.isModuleLoading = false;
}
});
}