In this script , why does ngClick work in the top link, but ngClick in the link to which I added the user directive does not work completely?
<a class="regular" ng-click="clickTheLink()">A regular ng-click link</a> <a class="disableable" disable="disableTheLink" ng-click="clickTheLink()">A disableable link!</a>
As far as I can tell, nothing that I do in the directive should interfere with the behavior of ngClick in general, since all it does is manipulate CSS classes:
app.directive('disableable', function(){ return { restrict: 'C', scope: { disable: '&' }, link: function (scope, elem, attrs) { scope.$watch(scope.disable, function (val) { if (val){ elem.addClass('disabled'); elem.removeClass('enabled'); } else { elem.addClass('enabled'); elem.removeClass('disabled'); } }); } }; });
source share