Zhihau Shiu
Zhihau Shiu

Reputation: 475

How to mix two ng-class expressions?

the real question:

<div ng-repeat="x in shoppingList |orderBy:'+done'|filter:search track by $index"  class="list-item" ng-class="{true: 'none-block', false: 'block'}[x.done&&hideMark]" style="padding-bottom:22px" >
    <a href="#" ng-click="done(x)" ng-class="{true: 'strike', false: 'default'}[x.done]" style="display:block">
          {{shoppingList.indexOf(x)}}. 
    <span class="thing" ng-bind="x.itemText"></span>
    </a></div>

Upvotes: 1

Views: 110

Answers (2)

Praveen Prasannan
Praveen Prasannan

Reputation: 7123

It should be

ng-class="{true: 'none-block strike', false: 'block default'}[x.done]"

Upvotes: 2

georgeawg
georgeawg

Reputation: 48948

ng-class="{'block default': !x[done], 'none-block strike': x[done]}"

Upvotes: 0

Related Questions