JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="questionnaire">
<div ng-controller="QuestionnaireCtrl">
<div ng-repeat="question in questions | orderByKey">
{{question.question}}
{{question.answer}}
</div>
</div>
</div>
JavaScript
(function(){
var app = angular.module('questionnaire',[]);
app.controller('QuestionnaireCtrl', function($scope){
$scope.questions = {
someItem: { question : 'First question' },
anotherItem: { question : 'Next question here' },
upgradeItem: { question : 'Another one' }
};
});
app.filter('orderByKey', [function () {
return function (input) {
if (!angular.isUndefined(input)) {
var tmpInput = [];
angular.forEach(input, function(value, key){
tmpInput.push(key);
});
tmpInput.sort();
var tmpOutput = [];
angular.forEach(tmpInput, function(key){
tmpOutput.push(input[key]);
});
return tmpOutput;
} else {
return input;
}
};
}]);
})();