使用到的对象:
$scope.student = { address: { select: { code: "0",name: "Select proof of address" },letter: { code: "1",name: "Letter" },photograph: { code: "3",name: "Photograph" } },------------------------------------ $scope.studentAddressFields = [ "select","letter","photograph" ]
要求:根据 选择的 studentAddressFields的项自动匹配到student 名称。
<select ng-model="current.addressCode"> <option ng-repeat="field in studentAddressFields" value="student.address[field]['code']"> {{student.address[field]['name']}} </option> </select>
方法2:使用filter
页面代码: <select ng-model="current.addressCode" ng-options="code as details.name for (code,details) in student.address | getOrdered"> </select> Filter JS代码: myApp.filter('getOrdered',function() { return function(input) { var ordered = {}; for (var key in input){ ordered[input[key]["code"]] = input[key]; } return ordered; }; });原文链接:https://www.f2er.com/angularjs/148242.html