-2

如何在角度视图(ng-repeat)循环中调用此 json 数据...

这是我的 json { "customers": [ { "id": 1, "firstName": "LoadTestName1", "lastName": "LoadTestLN1", "emailAddress": "loadtest1@gmail.com" }, { "id" : 2, "firstName": "LoadTestName2", "lastName": "LoadTestLN2", "emailAddress": "loadt" } ] }

4

2 回答 2

0

在控制器中:$scope.var1 = yourJson;

在视图中:

<div ng-repeat="item in var1.customers">
 {{item.firstName}} ...
</div>
于 2015-11-25T14:19:31.790 回答
0

剥去外大括号:

$scope.customers = [ {“id”:1,“firstName”:“LoadTestName1”,“lastName”:“LoadTestLN1”,“emailAddress”:“loadtest1@gmail.com”},{“id”:2,“ firstName": "LoadTestName2", "lastName": "LoadTestLN2", "emailAddress": "loadt" } ];

ng-repeat="customer in customers">
  <div>{{customer.firstName}}</div>
</div>
于 2015-11-25T14:22:08.923 回答