2017-07-13 171 views
1

數組假設我有一個休息,讓我回到這個JSON格式:動態創建一個JSON

​​

,並假設我要添加的所有dispatch_type在聲明這種方式選擇輸入:

<select ng-model="dispatchType" 
         ng-options="item as (item | uppercase) for item in searchFilterDispatcher.dispatchType" 
         class="form-control" id="dispatchType"> 
         <option value="">*</option> 
        </select> 

與這個js:

DispatcherFilterFactory.paramsMock().then(function(response) { 
          var result = response.data.result; 
          $scope.searchFilterDispatcher.dispatchType = result.dispatch_type ; 

         }); 

我應該如何設置循環該解析對象的陣列,所以我可以使用select?

回答

1

得到的"dispatch_type"

DispatcherFilterFactory.paramsMock().then(function(response) { 
    var result = {}; 
    result.dispatch_type = response.data.result.map(function (row) { 
    return row.dispatch_type; 
    }); 
    $scope.searchFilterDispatcher.dispatchType = result.dispatch_type; 
}); 
數組