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