angular-acl
angular-acl copied to clipboard
Cannot read property 'split' of undefined at aclShowWatchAction
In watching attrs.aclShow, we should check if value is not null

Hi @roselleebarle04 I change the code in angular-acl.js for this and fix my problem ;) I hope this resolve your problem
.directive('aclShow', function (AclService) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
scope.$watch(attrs.aclShow, function aclShowWatchAction(value) {
var permissions, can;
permissions = attrs.aclShow;
can = AclService.can(permissions);
if (!can) {
element.addClass(NG_HIDE_CLASS);
} else {
element.removeClass(NG_HIDE_CLASS);
}
});
}
};
});
@roselleebarle04 I am making it so null values cause the element not to show.
This fix is in the 0.1.10 release
Hi @mikemclin, I think this dont fix the problem =[
@luciano-work does this work for you?
.directive('aclShow', function (AclService) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
attrs.$observe('aclShow', function aclShowWatchAction(value) {
var permissions, can;
if (!value) {
element.addClass(NG_HIDE_CLASS);
return;
}
permissions = value.split(',');
can = AclService.canAny(permissions);
if (!can) {
element.addClass(NG_HIDE_CLASS);
} else {
element.removeClass(NG_HIDE_CLASS);
}
});
}
};
});
Doesn't work for me =( I have received an error in this code line: permissions = value.split(',');
Hi, we are having the same issue with this. Still not getting any values from value
attribute.