ng-repeat directive sort the data when using (key, value)

前端 未结 7 2130
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 09:40

I have a code something like this with ng-repeat = \"(key,value) in data\". In Controller:

  $scope.Dates = {\"Today\":\"30\",
                  \"This Wee         


        
7条回答
  •  攒了一身酷
    2020-12-08 09:51

    I was able to sort an Object of Strings by Key alphabetically like this with ng-repeat!

    In my controller:

    $scope.build_config = {
      build_path :  "/x/eng/build",
      arch : "x86",
      variant : "debug",
      run_method : "boot", 
    };
    
    $scope.get_keys = function (obj) {
      if (obj)
        return Object.keys(obj);
    };
    

    In my HTML:

    
           {{key}} 
           {{selected.build_config[key]}} 
    
    

提交回复
热议问题