Here is an array of objects that I am attempting to iterate in ng-repeat and print keys, but I am facing some challenges.
$scope.directivesInfo = [
{"ngRepeat": {"enter": true, "leave": true, "move": true, "add": false, "remove": false}},
{"ngView": {"enter": true, "leave": true, "move": false, "add": false, "remove": false}},
{"ngInclude": {"enter": true, "leave": true, "move": false, "add": false, "remove": false}},
{"ngSwitch": {"enter": true, "leave": true, "move": false, "add": false, "remove": false}},
{"ngIf": {"enter": true, "leave": true, "move": false, "add": false, "remove": false}},
{"ngClass": {"enter": false, "leave": false, "move": false, "add": true, "remove": true}},
{"ngShow/ngHide": {"enter": false, "leave": false, "move": false, "add": true, "remove": true}},
{"form/ngModel": {"enter": false, "leave": false, "move": false, "add": true, "remove": true}},
{"ngMessages": {"enter": false, "leave": false, "move": false, "add": true, "remove": true}},
{"ngMessage": {"enter": true, "leave": true, "move": false, "add": false, "remove": false}},
];
In my View, I have the following code -
<tr ng-repeat="(key, value) in directivesInfo">
However, key is only printing 0,1,2,3 and so on, but I want it to print the corresponding names like ngRepeat, ngView, and so forth.
Please note that I was able to achieve the desired result from a different array structure as shown below. But I am keen on achieving the same result from the above array declaration.
Successfully implemented with the following -
$scope.directivesInfo = [
{"name":"ngRepeat", "enter": true, "leave": true, "move": true, "add": false, "remove": false},
{"name":"ngView", "enter": true, "leave": true, "move": false, "add": false, "remove": false},
{"name":"ngInclude", "enter": true, "leave": true, "move": false, "add": false, "remove": false},
{"name":"ngSwitch", "enter": true, "leave": true, "move": false, "add": false, "remove": false},
{"name":"ngIf", "enter": true, "leave": true, "move": false, "add": false, "remove": false},
{"name":"ngClass", "enter": false, "leave": false, "move": false, "add": true, "remove": true},
{"name":"ngShow/ngHide", "enter": false, "leave": false, "move": false, "add": true, "remove": true},
{"name":"form/ngModel", "enter": false, "leave": false, "move": false, "add": true, "remove": true},
{"name":"ngMessages", "enter": false, "leave": false, "move": false, "add": true, "remove": true},
{"name":"ngMessage", "enter": true, "leave": true, "move": false, "add": false, "remove": false},
];
Final Output -
EDIT -