0

http://jsfiddle.net/48yh14c3/

this.list = [
 {
  property: [{anotherProp: true}]
 },
 {
  property: []
 },
 {
  property: [{anotherProp: false}]
 }
]

在角度 1 中,您可以引用深层属性,并且(在大多数情况下)它会继续摇摆:

<div ng-repeat='thing in ctrl.list'>
   {{thing.property[0].anotherProp}}
</div>

我确定我可以只 *ngIf 父属性以确保它存在,或者展平原始 POJO。只是想知道我是否遗漏了什么?

4

1 回答 1

2

是的,您缺少Elvis 运算符

<div *ngFor='#thing of list'>
   {{thing.property[0]?.anotherProp}}
</div>

Plunker

于 2015-12-17T20:27:18.907 回答