Reputation: 109
this is in my ng-repeat
, so I want if lp-image is not zero, apply class col-md-8 and else apply col-md-12 if it's zero. The result is strange, it returned col-md-12.
ng-class="{'col-md-8':item.lp-image != 0, 'col-md-12':item.lp-image == 0}">
Upvotes: 0
Views: 586
Reputation: 5826
Try this
ng-class="{'col-md-8':item['lp-image'] != 0, 'col-md-12':item['lp-image'] == 0}">
Upvotes: 1
Reputation: 2167
Your variable name cannot contain a hyphen -
, it's parsed as a minus operator. Use JavaScript's naming convention of camelCase, i.e. item.lpImage
.
Upvotes: 1