網址如何獲得請求的URL中後衛服務如何獲得請求中後衛角2
HasPermissionService
@Injectable()
export class HasPermissionService implements CanActivate{
private permissions = [];
constructor(private _core:CoreService,private route1:Router, private _route:ActivatedRoute ,private route: ActivatedRouteSnapshot,private state: RouterStateSnapshot) {
console.log('constructor calling ...');
// console.log(this.route.url);
this.permissions = this._core.getPermission();
console.log('inside guard');
console.log(this.permissions);
}
canActivate() {
console.log(this.route);
console.log(this._route);
return true;
}
}
,但我老了網址,從中我來自哪裏。如何獲取當前的網址?
路線
{path:'grade-listing',component:GradeListingComponent,canActivate:[HasPermissionService]}
我需要 '級,掛牌'
添加您的console.log在的setTimeout(()=> {的console.log(this.route)},0); – JSNinja