這裏我嘗試將數據加載到dropdownList其加載但爲什麼默認情況下,它從列表中選擇最後一個值。爲什麼選擇上一個值的下拉列表
的Html
<div ng-controller="Part5Controller">
Country : <select ng-model="CountryID" ng-options="I.CountryID as I.CountryName for I in CountryList" ng-change="GetState()">
<option value="">Select Country</option>
</select>
</div>
controller.Js
app.controller('Part5Controller', function ($scope, servicemard) {
getCountrys();
function getCountrys() {
var xx = servicemard.getctrys();
xx.then(function (d) {
$scope.CountryList = d.data;
})
}
})
service.js
app.service('servicemard', function ($http) {
this.getctrys = function() {
return $http.get('/Jan/GetCountries')
}
})
您可以添加'Jan/GetCountries'響應嗎? –