现在我正在使用ui-路由器来处理授权:
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {}但是,从Angular1.5开始,我如何使用ngComponentRouter来实现这个功能呢?
发布于 2015-12-08 06:09:21
在新路由器中有组件生命周期挂钩
angular.module('app', [])
.controller('MyController', ['user', '$http', MyController]);
function MyController(user, $http) {
this.user = user;
this.$http = $http;
}
// Before switching to a new component, this hook runs for
// each active component in the app. If any of them
// return false, a rejected promise, or a promise that resolves to false,
// the navigation is cancelled.
MyController.prototype.canActivate = function() {
return this.user.isAdmin;
};
//This hook fires just before the nagivation finishes.
MyController.prototype.activate = function() {
return this.bigFiles = this.$http.downloadBigFiles();
};https://stackoverflow.com/questions/34148854
复制相似问题