Create a gist now

Instantly share code, notes, and snippets.

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