How to iterate over the keys and values with ng-repeat in AngularJS?

后端 未结 9 1799
抹茶落季
抹茶落季 2020-11-22 04:36

In my controller, I have data like: $scope.object = data

Now this data is the dictionary with keys and values from json.

I can acce

9条回答
  •  Happy的楠姐
    2020-11-22 05:07

    we can follow below procedure to avoid display of key-values in alphabetical order.

    Javascript

    $scope.data = {
       "id": 2,
       "project": "wewe2012",
       "date": "2013-02-26",
       "description": "ewew",
       "eet_no": "ewew",
    };
    var array = [];
    for(var key in $scope.data){
        var test = {};
        test[key]=$scope.data[key];
        array.push(test);
    }
    $scope.data = array;
    

    HTML

    {{key}} : {{value}}

提交回复
热议问题