angular.js - Can json objects use ng-repeat
过去多啦不再A梦
过去多啦不再A梦 2017-05-15 17:05:43
0
2
560

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梦
过去多啦不再A梦

reply all(2)
过去多啦不再A梦
<p ng-repeat="(key, val) in data">
  key = {{key}}
  value = {{val}}
</p>
小葫芦

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>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template