這裏我使用WebApi,Mvc和Angularjs Bootstrap在這裏我成功地將數據加載到DropdownList但是爲什麼選擇dropdown select defalut lastvalue。爲什麼選擇動態下拉選擇上一個值Bydafults?
<select ng-model="CountryName" ng-options="I.CountryID as I.CountryName for I in CountryList" class="form-control">
<option value="-1" selected="selected">Select Country</option>
</select>
ctrls.Js
function GetCountryList() {
var ctrlList = MyService.GetCountrys();
ctrlList.then(function (d) {
$scope.CountryList = d.data;
})
}
你在'd.data'中有什麼?我的意思是'$ scope.CountryList' –
您是否在'$ scope.CountryName'中分配了任何值? –
我只是編輯我的代碼請參閱圖像 –