Skip to content

Instantly share code, notes, and snippets.

@ds82
Created August 2, 2013 09:57
Show Gist options
  • Save ds82/6138778 to your computer and use it in GitHub Desktop.
Save ds82/6138778 to your computer and use it in GitHub Desktop.
Application.Common.directive('ifRole', ["AuthService", function(AuthService) {
return {
restrict: "A",
transclude: "element",
scope: {},
compile: function(el, attrs, transclude) {
var currentUserRole = AuthService.currentUser.role;
var specifiedRole = attrs.ifRole;
return function(scope, el, attrs) {
if(currentUserRole == specifiedRole) {
var childScope = scope.$new();
transclude(childScope, function(clone) {
el.replaceWith(clone);
});
}
};
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment