AngularJS中的基本数组循环

时间:2018-09-10 08:49:14

标签: angularjs

有人可以向我解释为什么这种情况不会循环吗?

如果我在napIncident之前给出了空值。

我的代码

  <tr ng-repeat="napIncident in vm.NapIncidents">
                            <pre>{{vm.NapIncidents | json}}</pre>
                            <td>
                                {{napIncident.Incident}}
                            </td>

预输出

[
  {
    "NapIncident": {
      "Incident": "Zahlunsverbindungen ändern",
      "IncidentID": "0002724285",
      "NapID": "4214",
      "NapStatus": "erfasst",
      "Username": "silvat",
      "NumberOfApprovers": "2",
      "RecordDate": "12-12-2018",
      "CheckerInformationList": [
        {
          "CheckerInformation": {
            "Checker": "silvat",
            "Date": "21-09-2018",
            "TimeOfDay": "12:12:36",
            "CheckerInfo": "Something",
            "CheckerInfoText": "Something else"
          }
        }
      ],
      "Alterations": [
        {
          "Alteration": {
            "Field": "IBAN",
            "OldValue": "DE12345",
            "NewValue": "DE54321"
          }
        }
      ]
    }
  }
]

2 个答案:

答案 0 :(得分:0)

使用ng-repeat时,您将每个项目映射到一个临时变量,并且当您拥有命名文字数组(即NapIncident: {...}的数组时),您必须将NapIncident称为属性:< / p>

<tr ng-repeat="item in vm.NapIncidents">
  <td>
    {{ item.NapIncident.Incident }}
  </td>
  <td>
    {{ item.NapIncident.IncidentID }}
  </td>
</tr>  

以此类推。

答案 1 :(得分:0)

您必须访问您的商品。您的情况是napIncident。检查您的html部分,您会发现ng重复“ vm.NapIncidents中的NapIncident”。 要访问详细信息{{NapIncident.NapIncident.Incident}}