1
  • I have two ng-class expression.
  • ng-class="{true: 'none-block', false: 'block'}[x.done&x.hide]"
  • ng-class="{true: 'strike', false: 'default'}[x.done]"
  • How to mix them into one?

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>
Zhihau Shiu
  • 455
  • 6
  • 19

2 Answers2

2

It should be

ng-class="{true: 'none-block strike', false: 'block default'}[x.done]"
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
Praveen Prasannan
  • 7,093
  • 10
  • 50
  • 70
0
ng-class="{'block default': !x[done], 'none-block strike': x[done]}"
georgeawg
  • 48,608
  • 13
  • 72
  • 95