Gitaram Kanawade Gitaram Kanawade - 7 months ago 8
HTML Question

ng-class with dnyamic values and expression

I have following ng-class syntax with profileView.rating is value from API.

<span ng-class="{'badge-rating-{{profileView.rating}}*2':true}"></span>


I have to apply class for this span like badge-rating-1,badge-rating-5.Now If I have profileView.rating value 0.5 then for this span 'badge-rating-0.5*2'
How Can I solve this expression

Answer

You can do like this in your ng-class syntax

ng-class="{'badge-rating-{{(profileView.rating*2)}}':true}"
Comments