A jsonobject, I hope to traverse to obtain the key and value. Can I use ng-repeat to obtain it, or other simple methods to achieve the following effect;
The following jsonobject will report an error when using ng-repeat
$scope.data = {'aaa' : '123' , ‘bbb’:'456','ccc':'789'}
<p ng-repeat="m in data">
key = {{m.key}}
value = {{m.value}}
</p>
过去多啦不再A梦2017-05-15 17:07:43
<p ng-repeat="(key, val) in data">
key = {{key}}
value = {{val}}
</p>
高洛峰2017-05-15 17:07:43
You can refer to angular’s official explanation of ngRepeat:
Iterating over object properties
It is possible to get ngRepeat to iterate over the properties of an object using the following syntax:
<p ng-repeat="(key, value) in myObj"> ... </p>