将JSON对象数组绑定到Angular2 nativescript中的View

时间:2016-12-26 03:38:34

标签: angular nativescript

我有一个从我的API返回的JSON对象

2016-12-26 04:08:19

我正在使用Pipe过滤器将此Object转换为数组并尝试在View中显示Passengers First Name。但我无法检索

{
"ID": "GM5VY",
"Passengers": [
 {
"Firstname": "TEST",
"Lastname": "TRAVELLER",
"TotalCount": "1",
FqtT": [
  {
    "MembershipID": "XXXXXX"
  }
],
"Errors": null,
"Information": null,
"Warnings": null
}
],
"Errors": null,
"Information": null,
"Warnings": null
}

请帮助我实现这个!!!

1 个答案:

答案 0 :(得分:2)

如何使用更简单的方法迭代数组:

<StackLayout *ngFor="let passenger of PassengerDetails.Passengers">
  <Label [text]="passenger.Firstname"></Label>
</StackLayout>