I am having issue with $index in angular.I have a ng-repeat inside which I am using $index to keep track of unique class.
Here is my code:
<div ng-repeat="style in styleArr">
<div class="myclass{{ $index }}">
</div>
</div>
In angular controller I am appending a div inside myclass0,But not working. Here is my controller.
myClass = angular.element('.myclass0');
myClass.append('<div class="test">Hello World..<test>');
When I try to do this:
<div ng-repeat="style in styleArr">
<div class="myclass0">
</div>
</div>
Its working fine.Any suggestion?
ng-class, however I think your issue is you're trying to append to elements like you would in jquery, this is not generally the angular way of going about this. My guess is the myClass you are setting is looking for the element before the repeat has run. You don't want to do DOM manipulations like that from the controller. What are you trying to achieve?