Skip to content

Instantly share code, notes, and snippets.

@benheymink
Created April 1, 2015 12:17
Show Gist options
  • Save benheymink/994ee1ce00ae064cb4fa to your computer and use it in GitHub Desktop.
Save benheymink/994ee1ce00ae064cb4fa to your computer and use it in GitHub Desktop.
Simple RBA directive
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