1
當我點擊編輯按鈕,下拉菜單沒有出現,但是當我在Insepect模式追溯其它值顯示 的Html使用Angular如何在編輯模式下綁定下拉控件?
<table>
<tr>
<td>
<input type="button" class="btn btn-sm btn-primary" value="Edit" ng-click="Edit(Ass)" />
</td>
</tr>
</table>
<div>
<b>Country</>
<div>
<select name="cntr" data-ng-show="Ass.CountryName" ng-options=" I.CountryID as I.CountryName for I in CountryList track by I.CountryID" ng-model=" CountryID" class="form-control" ng-change="GetStates()" ng-class="submitted?'ng-dirty':''" required>
<option ng-repeat="ss in CountryList" value="ss" ng-selected="Ass.ss.CountryName">{{ss}}</option>
</select>
<span class="Error" ng-show="(f1.cntr.$dirty ||submitted) && f1.cntr.$error.required">Select Country</span>
</div>
</div>
</div>
</div>
Angular.Js
function CountryList() {
var x = $Myservice.GetCountrys();
x.then(function (d) {
$scope.CountryList = d.data;
//$scope.selectedItem = CountryList;
})
}
<選擇name =由一 「CNTR」 的數據-NG-秀= 「Ass.CountryName」 NG選項=」 I.CountryID對我的I.CountryName在CountryList軌道CountryID「ng-model =」CountryID「class =」form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-hide「ng-change =」GetStates()「ng-class =」提交?'ng-dirty':''「required =」「><選項標籤=「RSA」值=「4」> RSA –
所以你的選擇/下拉列表是在瀏覽器中可見 –
可以CONSOLE.LOG Ass.CountryName看到它的價值。在你的控制器中應該有$ scope.Ass.CountryName –