Created
April 1, 2015 12:17
-
-
Save benheymink/994ee1ce00ae064cb4fa to your computer and use it in GitHub Desktop.
Simple RBA directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.directive('accessControl', function (userService) { | |
return { | |
restrict: 'A', | |
replace: false, | |
scope: { | |
permittedRoles: '=' | |
}, | |
link: function (scope, element) { | |
var roles = userService.getUserRoles; | |
var matchingRoles = _.intersection(roles, scope.permittedRoles); | |
if(matchingRoles.length === 0){ | |
element.remove(); | |
} | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment