Search code examples
javascriptangularjsng-class

ngClass issue in angular 1.5


I'm developing a site in angular 1.5, in order to make it on angular 2, when stable.

I have this code:

<li ng-class="day==1 ? a : b" ng-repeat="day in $ctrl.daysMap">
    {{day}}
</li>

the ng-repeat is being repeating the li correctly. Now I need for every li created to add class to that li, depending on the current position of daysMap.

I though the ng-class like above should work, but neither class is added to the li, instead of that, the ng-class is showed in the html, but no class is added


Solution

  • This would work if a and b where valid $scope properties. If they were strings, it needs to look like this:

    ng-class="day==1 ? 'a' : 'b'"