In this AngularJS associative array (array of key,value pairs), ng-repeat is not functioning properly. What's wrong?
function TestCtrl($scope) {
$scope.list = [];
$scope.processSomeData = function(){
$scope.list["testKey"]={};
$scope.list["testKey"]["test"]="Test value";
};
$scope.processSomeData();
}
<div ng-app>
<h2>Test</h2>
<div ng-controller="TestCtrl">
<div ng-repeat="(key,value) in list">
{{key}}
{{value.test}}
</div>
</div>
</div>
Thanks!
Your "associative array" should be an Javascript Object and not a Javascript Array. You cannot use js Arrays in AngularJS for key, value pairs/maps.
Change your list to an Object and it will work:
$scope.list = {};