Reputation: 49
I have my div like the following...
<div class="slider-slide-wrap current_year shown slide{{yr}}" ng-repeat="yr in yeardata"></div>
in {{yr}} I am getting stored year data.Here I need to check the condition If {{yr}} == {{currentyear}} then I need to add the classes 'shown' and 'current_year ' to the div .
How is this possible??
Upvotes: 0
Views: 55
Reputation: 140
you can use directive ng-class
<div **ng-class={'shown current_year': yr == currentyear, }** class="slider-slide-wrap current_year shown slide{{yr}}" ng-repeat="yr in yeardata"></div>
Upvotes: 1
Reputation: 366
You should use ng-class
(link to the docs: https://docs.angularjs.org/api/ng/directive/ngClass)
You can set a class based on a condition with it, using it like this:
<div ng-class={ 'your-class': year === currentYear }></div>
The ng-class argument is a dictionary, so you can set multiple classes with it (like you wanted to), using it like:
<div ng-class={ 'your-class': year === currentYear, 'your-second-class': year === currentYear }></div>
Upvotes: 0