Seyong Cho Seyong Cho - 10 months ago 91
AngularJS Question

AngularJS ng-class not working in ng-repeat with $index

I have a list created with ng-repeat that works for everything except for adding the ng-class on condition.

<div ng-repeat="glossary in glossarySections"
ng-class="{'selected',$index == $parent.glossarySection}">

ng-click works, and it creates the DOM the way I expect it to, but it doesn't add the 'selected' class for the alphabet currently shown.

Is there something that I am missing in this syntax?

Joy Joy

There is a syntax error: replace , to :.

Modify to ng-class="{'selected': $index == $parent.glossarySection}">.