0
angularjs로 돌아 가기 (ui-router 사용). 메타 데이터를 경로에 추가하고 routechanges의 메타 데이터를 사용할 수 있습니다.경비원의 각진 경로 메타 데이터
각도에 따라 경비원이 있지만 경로 정의에서 메타 데이터를 가져 오는 방법을 알아낼 수 없습니다.
좀 더 구체적인 예를 들자면 경로에 메타 데이터를 추가하고 필요한 역할 및 권한을 말하고 경비원이 무거운 것을 수행하도록하고 싶습니다.
경로 정의 : 내 가드에
RouterModule.forChild([
{
path: '',
component: MyComponent,
data: {
permissions: ["view"],
roles: ["admin", "user"]
}
},
...
]);
: 그리고
constructor(private myService: MyService, private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
//How to get a hold of the data defined for the current route ?
console.log(route.data); //returns an empty object
}
사실 내 경계면이 잘못된 경로 정의에 있다는 사실을 나중에 깨달았습니다. 어쨌든 고마워. – RVandersteen