Reputation: 1097
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"
class="alphabet"
ng-click="glossaryGoToSection($index)"
ng-class="{'selected',$index == $parent.glossarySection}">
{{glossary.name}}
</div>
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?
Upvotes: 0
Views: 629
Reputation: 14992
ngClass
receives a hash object: class: condition
So you should use colon for key/condition separation:
ng-class="{selected: $index==$parent.glossarySection}"
Upvotes: 1
Reputation: 9560
There is a syntax error: replace ,
to :
.
Modify to ng-class="{'selected': $index == $parent.glossarySection}">
.
Upvotes: 1