Below is the directive I wrote,
angular.module('netVogue.directives', []). directive('set-First-Active', function() { return function(scope, element, attrs){ alert('sample'); element.addClass("active"); }; });
I have added this directive to my module below,
angular.module('netVogue', ['netVogue.filters', 'netVogue.services', 'netVogue.directives']);
I used this directive in my template in the following format,
<div class="item" ng-repeat="viewPrintcampaign in viewPrintcampaigns" ng-init="first=$first" set-First-Active> </div>
However, I do not see any response to the warning, and the class is not added. Can someone please help me with this? Due to some dependency, I don't want to use 'ng-class', but I want to add class = 'active' for the first ng-repeat element.
Any help would be greatly appreciated. Thanks in advance.
Abdul azeez
source share