angular路由守卫

import { CanActivateChild, Router, ActivatedRouteSnapshot } from '@angular/router';
export class AuthGuard implements CanActivateChild {
public async canActivateChild(childRoute: ActivatedRouteSnapshot) {
const toOpen = childRoute.routeConfig.path === 'child' 
if (toOpen) {
this.buyAcc.getSub().subscribe((res) => {
if (res['status'] !== 0) {
this.modal.warning({content: res['data']});
return false;
}
});
} else {
return true;
}
}
}
posted @ 2019-01-25 11:32  前端小厨-美食博主  阅读(177)  评论(0编辑  收藏  举报