I have an array in Angular like this:
$scope.test = [
{'item1' : 'answer1' },
{'item2' : 'answer2' },
{'item3' : 'answer3' }
];
And so on...
Now there's 2 things I want to do. Firstly I want to use an ng-repeat to iterate through the array and display the keys and values separately. I tried this:
<div ng-repeat="(key,value) in test">
{{key}} = {{value}}
</div>
But that produces results like this:
0 = {"item1" : "answer1"}
1 = {"item2" : "answer2"}
2 = {"item3" : "answer3"}
Whereas I want it to display like this:
item1 = answer1
item2 = answer2
item3 = answer3
The second thing I'd like to do is use the keys to display results from a different array. For example I have this array:
$scope.item1.question = 'some question';
So as I'm going through the ng-repeat I'd like to do something like this:
{{key}}.question
to display the string 'some question'
.
But this doesn't do anything...