这里我使用带有Anagular的Mvc i当我点击编辑按钮时将数据显示到表中为什么模态弹出窗口没有绑定该列值。如果我想仅使用chane名称,那么国家/地区状态值将变为空
自举
<div id="AssTable">
<table class="table table-striped table-responsive ">
<tr>
<th><b>Id</b></th>
<th> <b>CountryName</b></th>
<th><b>StateName</b></th>
<th><b>Actions</b></th>
</tr>
<tr ng-repeat="Ass in AssData">
<td>{{Ass.Id}}</td>
<td>{{Ass.CountryName}}</td>
<td>{{Ass.StateName}}</td>
<td>{{Ass.CityName}}</td>
<td>
<input type="button" class="btn btn-sm btn-primary" value="Edit" ng-click="Edit(Ass)" />
</td>
</tr>
</table>
</div>
<div class="modal" id="modal1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<form name="f1" novalidate ng-submit="Save(emp)">
<div class="form-group">
<div class="row">
<div class="col-sm-4">
<b style="font-family:Arial;text-transform:capitalize">Enter Name</b>
</div>
<div class="col-sm-8 left-addon">
<input type="text" name="nam" class="form-control" ng-minlength="8" ng-maxlength="10" ng-model="Name" ng-class="submitted?'ng-dirty':''" required autofocus />
<i class="glyphicon glyphicon-user"></i>
<span class="Error" ng-show="(f1.nam.$dirty ||submitted) && f1.nam.$error.required">Please Enter Your Name</span>
<span class="Error" ng-show="f1.nam.$error.minlength">Mobile number should be minimum 8 character</span>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-4">
<b style="font-family: Arial; text-transform: capitalize; text-align: left">Country</b>
</div>
<div class="col-sm-8 left-addon">
<select name="cntr" ng-options=" I.CountryID as I.CountryName for I in CountryList" ng-model=" CountryID" class="form-control" ng-change="GetStates()" ng-class="submitted?'ng-dirty':''" required>
<option ng-repeat="d in CountryList track by $index" value="$index" ng-selected="true">{{d.CountryName}}ffff</option>
</select>
<span class="Error" ng-show="(f1.cntr.$dirty ||submitted) && f1.cntr.$error.required">Select Country</span>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-4">
<b style="font-family: Arial; text-transform: capitalize; text-align: left">States</b>
</div>
<div class="col-sm-8 left-addon">
<select name="Sts" ng-options="I.StateID as I.StateName for I in StateList" ng-model="StateID" class="form-control" ng-change="GetCities()" ng-class="submitted?'ng-dirty':''" required>
<option value="">{{StateName}} </option>
</select>
<span class="Error" ng-show="(f1.Sts.$dirty ||submitted) && f1.Sts.$error.required">Select States</span>
</div>
</div>
</div>
<div class="modal-footer">
<input type="submit" value="{{validate}}" class="btn btn-info btn-sm" />
</div>
</form>
</div>
</div>
</div>
</div>
AgularCode
/ 国家/地区代码 /
$scope.GetStates = function () {
// alert('ok')
var xx = $Myservice.GetStates($scope.CountryID);
xx.then(function (d) {
$scope.StateList = d.data;
})
}
/ 编辑AccessData /
$scope.Edit = function (Ass) {
var editId = $Myservice.EditById(Ass.Id);
editId.then(function () {
$scope.Name =Ass.Name,
$scope.CountryName = Ass.CountryName,
$scope.CountryID=Ass.CountryID,
$scope.StateName = Ass.StateName,
$('#modal1').modal('show')
$scope.validate = "UPDATE";})
}