angular-acl icon indicating copy to clipboard operation
angular-acl copied to clipboard

Cannot read property 'split' of undefined at aclShowWatchAction

Open roselleebarle04 opened this issue 7 years ago • 7 comments

In watching attrs.aclShow, we should check if value is not null

screen shot 2017-07-11 at 6 54 20 am

roselleebarle04 avatar Jul 10 '17 22:07 roselleebarle04

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);
        }
      });
    }
  };
});

lannodev avatar Jul 20 '17 18:07 lannodev

@roselleebarle04 I am making it so null values cause the element not to show.

mikemclin avatar Jul 21 '17 15:07 mikemclin

This fix is in the 0.1.10 release

mikemclin avatar Jul 21 '17 15:07 mikemclin

Hi @mikemclin, I think this dont fix the problem =[

image

lannodev avatar Jul 21 '17 15:07 lannodev

@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);
        }
      });
    }
  };
});

mikemclin avatar Jul 21 '17 15:07 mikemclin

Doesn't work for me =( I have received an error in this code line: permissions = value.split(',');

lannodev avatar Jul 21 '17 18:07 lannodev

Hi, we are having the same issue with this. Still not getting any values from value attribute.

ivanvastag avatar Jul 26 '17 13:07 ivanvastag