Skip to content

Instantly share code, notes, and snippets.

@windwp
Created August 23, 2016 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windwp/90c46d41d283ad5a483dade6caedc4c8 to your computer and use it in GitHub Desktop.
Save windwp/90c46d41d283ad5a483dade6caedc4c8 to your computer and use it in GitHub Desktop.
angular
//disable angular xeditable disable-permission-xedit="permission"
angular.module("pmt").directive("disablePermissionXedit", function(UserService) {
function compile(el, attr) {
if (!UserService.hasPermissionBool(attr.disablePermissionXedit)) {
var hasDirective = el[0].querySelectorAll("[editable-text]");
[].forEach.call(hasDirective, function(el) {
el.removeAttribute('editable-text');
});
hasDirective = el[0].querySelectorAll("[editable-select]");
[].forEach.call(hasDirective, function(el) {
el.removeAttribute('editable-select');
});
hasDirective = el[0].querySelectorAll("[editable-textarea]");
[].forEach.call(hasDirective, function(el) {
el.removeAttribute('editable-textarea');
});
hasDirective = el[0].querySelectorAll("[editable-date]");
[].forEach.call(hasDirective, function(el) {
el.removeAttribute('editable-date');
});
}
}
return {
restrict: 'A',
priority: 100000,
compile: compile
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment