在角度应用程序中,我有2个页面,每个页面根据用户的privileged
级别。因此,如何通过使用resolve
或不使用从router
重定向模板?Angular-route:如何从`resolve`方法切换模板?
什么是正确的方法?
这里就是我在寻找:
$routeProvider.when('/secretpage' , {
templateUrl: null,
resolve:{
"check":function(accessFac,$location){
if(accessFac.checkPermission()){
//check if the user has permission -- This should happen before the page loads
return this.template: "templates/secretpage.html"
} else {
this.template: "templates/secretlesspage.html"
}
}
}
})