Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Provides a directive to toggle display of elements.
  3.  */
  4. angular.module('security.access', ['services.authentication'])
  5.  
  6.   .directive('accessLevel', ['authentication', function(authentication) {
  7.     return {
  8.       restrict: 'A',
  9.       link: function(scope, element, attributes) {
  10.         var accessLevel = attributes.accessLevel;
  11.         var display = element.css('display');
  12.         var role = authentication.user.role;
  13.  
  14.         attributes.$observe('accessLevel', function(accessLevel) {
  15.         })
  16.  
  17.         function toggleElement() {
  18.           if (!authentication.authorize(accessLevel, role)) {
  19.             element.css('display', 'none');
  20.           }
  21.           else {
  22.             element.css('display', display);
  23.           }
  24.         }
  25.       },
  26.     }
  27.   }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement