I try to use JavaScript Maps in the ng-repeat angular directive while searching, I found that this can be done as follows:
<ul ng-controller="MyCtrl"> <li ng-repeat='(key, value) in {"First Name":"John", "Last Name":"Smith"}'> <span>Key: {{key}}, value: {{value}}</span> </li> </ul>
but this only works with regular JSON objects, when I create a real map as follows, it does not work.
I have this controller, for example
function MyCtrl($scope) { $scope.items = new map(); $scope.items.set('adam',{'age':10,'fav':'doogie'}); $scope.items.set('amalie',{'age':12}); }
and this html code
<ul> <li ng-repeat='(key, value) in items'> <span>Key: {{key}}, value: {{value}}</span> </li> </ul>
javascript angularjs angularjs-ng-repeat
Xsmael May 19 '17 at 14:56 2017-05-19 14:56
source share