使用ng-repeat遍历json对象

ng-repeat 可以遍历数组对象,也可以遍历json对象:

$scope.data =  {'aaa' : '123' , ‘bbb’:'456','ccc':'789'};
<div ng-repeat="(key, val) in data">
  key = {{key}}
  value = {{val}}
div>

参照一下angular官方对ngRepeat的讲解:
Iterating over object properties
It is possible to get ngRepeat to iterate over the properties of an object using the following syntax:

repeat="(key, value) in myObj"> ...

以上总结来源参照:
https://segmentfault.com/q/1010000006660025?_ea=1087793

你可能感兴趣的:(angular,angular)