Arrays AngularJS-如何访问数组中的对象数组
在c#中,我创建了一个数组,其中包含一个对象数组,并将其传递给Angular Angular通过以下方式接收:Arrays AngularJS-如何访问数组中的对象数组,arrays,angularjs,nested,Arrays,Angularjs,Nested,在c#中,我创建了一个数组,其中包含一个对象数组,并将其传递给Angular Angular通过以下方式接收: $scope.accounts = data.items; 在我的cshtml中,我可以很好地访问这些值: <td>{{account.name}}</td> <td>{{account.primaryAccountManager}}</td> <td>{{account.secondaryAccountManager}}&
$scope.accounts = data.items;
在我的cshtml中,我可以很好地访问这些值:
<td>{{account.name}}</td>
<td>{{account.primaryAccountManager}}</td>
<td>{{account.secondaryAccountManager}}</td>
{{account.name}
{{account.primaryAccountManager}
{{account.secondaryAccountManager}
但不是:
<td>{{account.subscriptions.expirationDate}}</td>
{{account.subscriptions.expirationDate}
要获取嵌套数组中的expirationDate,我需要做什么?您需要使用
[ng repeat]
指令在数组上循环
试试看
<div ng-repeat="subscription in account.subscriptions">
{{subscription.expirationDate}}
</div>
{{subscription.expirationDate}
别忘了检查你的文件
如果您处于ng重复中,请使用:
<td>{{account.subscriptions[$index].expirationDate}}</td>
{{account.subscriptions[$index].expirationDate}
可能是{{account.subscriptions[i].expirationDate}?您能给我们看一下您的数据项吗array@luk492您从何处获得[i]?accounts数组的结构如何?如果您需要适当的帮助,请提供示例数据和预期结果