ng-hide取决于var的值

时间:2013-05-29 12:33:02

标签: angularjs

在AngularJS中,我如何执行以下代码尝试实现的目标,即如果task.status设置为特定值,则隐藏跨度?

<li ng-repeat="task in tasks">

    Move to:
    <span ng-hide="task.status=todo">Todo</span>
    <span ng-hide="task.status=doing">Doing</span>
    <span ng-hide="task.status=done">Done</span>

</li>

1 个答案:

答案 0 :(得分:4)

<li ng-repeat="task in tasks">
    Move to:
    <span ng-hide="task.status == todo">Todo</span>
    <span ng-hide="task.status == doing">Doing</span>
    <span ng-hide="task.status == done">Done</span>
</li>

<li ng-repeat="task in tasks">
  <div ng-switch on="task.status" >
    <span ng-switch-when="todo">Todo</div>
    <span ng-switch-when="doing">Doing</div>
    <span ng-switch-when="done">Done</div>
  </div>
</li>