Skip to content

Instantly share code, notes, and snippets.

@vvscode
Created November 15, 2015 07:35
Show Gist options
  • Save vvscode/9c2a5b72cb7c7160809f to your computer and use it in GitHub Desktop.
Save vvscode/9c2a5b72cb7c7160809f to your computer and use it in GitHub Desktop.
onlyForAdmin directive
angular
.module('smartjs').directive('onlyForAdmin', function(ngIfDirective) {
ngIfDirective = ngIfDirective[0];
return {
transclude: ngIfDirective.transclude,
priority: ngIfDirective.priority,
terminal: ngIfDirective.terminal,
restrict: ngIfDirective.restrict,
link: function($scope, $element, $attr) {
$attr.ngIf = 'user.isAdmin';
ngIfDirective.link.apply(ngIfDirective, arguments);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment