Being a newcomer to angularjs, I am facing difficulty in resolving this issue.
Custom Directive
app.directive('rating', [function () {
return {
restrict: 'E',
scope: {
maxStars: '=',
},
link: function (scope, iElement, iAttrs) {
scope.stars = [];
for(var i=0;i<scope.maxStars;i++) {
scope.stars.push(i);
}
iElement.bind('mouseenter', function(event) {
scope.$apply(function(){
angular.forEach(iElement.children(),function(div){
angular.forEach(div.children,function(span){
span.addClass('rating-star-enabled'); //error addClass is not a function
});
});
});
});
},
templateUrl:'rating/rating.html'
};
}]);
Template of the Custom Directive
<div class="review-star">
<span class="glyphicon glyphicon-record" ng-repeat="star in stars"></span>
</div>
Usage of Custom Directive
<rating max-stars="5"></rating>
I keep encountering the error "addClass is not a function." This issue persists with other functions as well, and when I log it in the console, all tags are being displayed correctly. What could be the cause of this error?