在指令中,我无法访问位于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 currentUserHasAnyPermissionhttps://stackoverflow.com/questions/51350167
复制相似问题