I just asked about generating a select from key/value map instead of array: AngularJS select box generated from object
That is all working fine now: http://jsfiddle.
Solution 1: You can use another array to store the order of the fields. For this you would need to use ng-repeat
in place of ng-options
:
$scope.studentAddressFields = [
"select",
"letter",
"photograph"
]
HTML:
Solution 2: Using a filter:
HTML:
Filter:
myApp.filter('getOrdered', function() {
return function(input) {
var ordered = {};
for (var key in input){
ordered[input[key]["code"]] = input[key];
}
return ordered;
};
});