0
里面NG重复填充一定值下拉列表中,我有一个必须要充满某些选定的值,如果没有在obj.Name1数据选择下拉否则应选择在默认的第一个值选项。Angularjs,如选择
<table ng-controller="TestCtrl">
<tr ng-repeat="obj in MainArray" >
<td>{{$index + 1}}</td>
<td ng-model="MainArray">{{obj.FirstValue}}</td>
<td>
<!-- if obj.Name1 has some value then it has to be selected in select dropdown, else default first value of dropdown must be displayed -->
<!-- dont know how to put a condition so as to display the obj.Name1 value in the dropdown-->
<select ng-model="DropdownArray[$index]" ng-options="test.ID as test.Name for test in DropdownList" >
<option>Default Value</option>
</select>
</table>
//控制器
.controller('TestCtrl',function($scope, $rootScope, $http, URL, $state, $modal, $interval, Notification){
$scope.DropdownArray=[];
$scope.DropdownList=[
{"ID":"1","Name":"one"},
{"ID":"2","Name":"two"},
{"ID":"3","Name":"three"}
];
$scope.MainArray=[
{"FirstValue":"First","Name1":""} ,
{"FirstValue":"Second","Name1":"two"} ,
{"FirstValue":"Third","Name1":"one"},
{"FirstValue":"Forth","Name1":""}
];
})
我的问题是,如果obj.Name1
包含任何值,我怎么能显示它作为选择的选项?
究竟什么是你的问题? – AlexMA
如果obj.Name1包含任何值,那么我如何显示它作为选定的选项 例如,{“FirstValue”:“Second”,“Name1”:“two”} Name1的值为2,显示为选定选项(在DropdownArray [$ index]中) – venkatesh52