Created
August 21, 2014 02:13
-
-
Save afcastano/cb6f8ecdaa8dcb07e875 to your computer and use it in GitHub Desktop.
Directive layout for restricting HTML elements depending on the user roles
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
app.directive('restrict', function(authService){ | |
return{ | |
compile: function(element, attr, linker){ | |
//attr.access is an attribute on the element with the roles that apply for that element. | |
var authorized = authService.isAuthorized(attr.access); | |
if(!authorized){ | |
// Remove element from DOM. | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment