如何混合两个ng-class表达式?

时间:2015-12-09 17:12:49

标签: angularjs ng-class

  • 我有两个ng-class表达式。
  • ng-class =“{true:'none-block',false: 'block'} [x.done& x.hide]“
  • ng-class =“{true:'strike',false: 'default'} [x.done]“
  • 如何将它们混合成一个?

真正的问题:

<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>

2 个答案:

答案 0 :(得分:2)

应该是

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

答案 1 :(得分:0)

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