Skip to content

Instantly share code, notes, and snippets.

@fnakstad
Created July 18, 2013 21:00
Show Gist options
  • Select an option

  • Save fnakstad/6033059 to your computer and use it in GitHub Desktop.

Select an option

Save fnakstad/6033059 to your computer and use it in GitHub Desktop.
angular.module('angular-client-side-auth')
.directive('accessLevel', ['$rootScope', 'Auth', function($rootScope, Auth) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var prevDisp = element.css('display');
$rootScope.$watch('user.role', function(role) {
if(!Auth.authorize(attrs.accessLevel))
element.css('display', 'none');
else
element.css('display', prevDisp);
});
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment