在指令中,我无法进入authService中的getUser
方法:
angular.module('app').directive('guard', [ function ( authService) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
// element.hide();
function currentUserHasAnyPermission(requiredP) {
return authService.getUser().then(function (currentUser) {
var currentUserP = currentUser.permissions;
return _.intersection(currentUserP, requiredP).length > 0;
});
}
}
};
}]);
返回错误:
Cannot read property 'getUser' of undefined
at currentUserHasAnyPermission