只有医院下拉代码在下拉显示中显示“HOSPITAL 1”,但是当我刷新页面时,病房下拉代码没有显示“WARD 1”。
每次刷新页面时,都会调用医院下拉菜单中的ng-change,并根据所选医院“HOSP1”检索相应的病房,但病房下拉菜单的显示将设置为“请选择病房”而不是“WARD1”。
我试图保留旧的wardCode =='WARD1',就像我在控制器中为hosp所做的那样,但是在ng-change被触发后值变化无效。
有人知道我在这种情况下是否可以使用角度复制吗?
HTML
<div class="form-group">
<label class="control-label">Hosp</label>
<select ng-model='search.hosp'select-options=" {{hosp}}" select-data="
{{search.hospCode}}" ng-change="wardDropdown()" id="hospCode"
name="hospCode">
<option value="">Please Select Hosp</option>
<option ng-repeat="obj in hosp" value="{{obj.VALUE}}">{{obj.LABEL}}
</option>
</select>
</div>
<div class="form-group">
<label class="control-label">Ward</label>
<select ng-model='search.wardCode' select-options="{{wards}}"
select-data="{{search.wards}}" id="wardCode" name="wardCode">
<option value="">Please Select Ward</option>
<option ng-repeat="obj in wards" value="{{obj.VALUE}}">
{{obj.LABEL}}
</option>
</select>
</div>
JS
$scope.search = {}
$scope.search.hosp = 'HOSP1';
$scope.search.wardCode = 'WARD1';
//Start, hosp dropdown list
$scope.hosp = function () {
var url = /searchHosp',
method = methodType.POST,
functionName = 'searchHosp',
params = {};
if (data.status == messageStatus.success) {
$scope.hospitals = data.result;
} else {
$scope.errorMessage = promptMessage.searchRecordFailure;
}
},
function (error) {
$scope.errorMessage = promptMessage.exception;
)
};
$scope.hospitalList();
//End, hosp dropdown
//Start, ward dropdown
$scope.wardDropdown = function () {
var url = searchWard,
method = methodType.POST,
functionName = 'searchWard',
params = {};
params.hosp = $scope.search.hosp;
if (data.status == messageStatus.success) {
$scope.wards = data.result;
}
}
else {
$scope.errorMessage = promptMessage.searchRecordFailure;
}
$scope.wardDropdown();
//End, ward dropdown list