I'm new to Angular js and was wondering how to make an ng class apply based on a set of conditions. For example i want to have a set of dates using ng repeat and change the colour of the date if that date is greater than the current date. My question is how would i go about this?
Asked
Active
Viewed 328 times
1 Answers
0
ng-class="{'testClass': val == 10}"
this will add class testClass
to the element when val is equals to 10

Kalhan.Toress
- 21,683
- 8
- 68
- 92
-
what if i wanted to evaluate an say currentDate > Date where the date is bound to a scope eg $scope.Date and scope.currentDate – Indrick Nov 13 '14 at 10:09
-
So your problem is how to check that a date is after another date or how to express the comparison inside an ng-class? In the first case I suggest you to use momentjs and its isAfter() function, and for the second case you simply put the result of this function in the ng-class: `ng-class="{'testClass': moment(currentDate).isAfter(Date)}"` – kasimoglou Nov 13 '14 at 10:17