2015-04-27 113 views
-3
{"id":1,"firstName":"John1","lastName":"Doe1","**accountIds**":[12345,12346,12347],"recipients":[{"accountNumber":22222,"firstName":"Mary1","lastName":"Jane1"},{"accountNumber":33333,"firstName":"Mary2","lastName":"Jane2"}]} 

顯示「accountIds」是下拉列表。如何獲取json數組值並顯示在angularjs中的dropdwon列表中?

+0

可以refer.http://stackoverflow.com/questions/24453174/displaying-json-data-in-drop-down-in -angularjs – gihan

回答

0

請參閱jsfiddle附http://jsfiddle.net/HB7LU/13213/

您需要使用點符號來定位accountIds

HTML

<div ng-controller="MyCtrl"> 
    <select> 
     <option ng-repeat="item in items.accountIds">{{item}}</option> 
    </select> 
</div> 

JS /角

var myApp = angular.module('myApp', []); 

function MyCtrl($scope) { 
    $scope.items = { 
     "id": 1, 
     "firstName": "John1", 
     "lastName": "Doe1", 
     "accountIds": [12345, 12346, 12347], 
     "recipients": [{ 
      "accountNumber": 22222, 
      "firstName": "Mary1", 
      "lastName": "Jane1" 
     }, { 
      "accountNumber": 33333, 
      "firstName": "Mary2", 
      "lastName": "Jane2" 
     }] 
    } 
} 
相關問題