Skip to content

Instantly share code, notes, and snippets.

@afcastano
Created August 21, 2014 02:13
Show Gist options
  • Save afcastano/cb6f8ecdaa8dcb07e875 to your computer and use it in GitHub Desktop.
Save afcastano/cb6f8ecdaa8dcb07e875 to your computer and use it in GitHub Desktop.
Directive layout for restricting HTML elements depending on the user roles
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