Instantly share code, notes, and snippets.

What would you like to do?
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){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment