我有这个对象

people = [{name: "John", registered: true },{name: "Micky", registered: false },{name: "Carol", registered: true }]


而且我有这个角度的HTML:

<ul>
  <li ng-repeat="person in people">
    {{person.name}}
    <div class="already-registered-icon">&nbsp;</div>
  </li>
</ul>


我的问题是-如何使仅当用户已经注册时才显示注册图标的条件?

我会想到这样的东西(但是我不知道怎么写):

{{if person.registered}}
        <div class="already-registered-icon">&nbsp;</div>
{{end}}

最佳答案

只需使用ngShow

<div ng-show="person.registered" class="already-registered-icon">&nbsp;</div>


演示:http://jsbin.com/usodaw/1/

关于javascript - 如何使用AngularJS在HTML中创建条件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14441001/

10-09 21:15