0

我有这个对象

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

2 回答 2

2

只需使用ngShow

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

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

于 2013-01-21T14:51:55.160 回答
0

这是ng-show我缺少的属性

<ul>
  <li ng-repeat="person in people">
    {{person.name}}
    <div ng-show="person.registered" class="already-registered-icon">&nbsp;</div>
  </li>
</ul>
于 2013-01-21T14:52:37.493 回答