我的页面上有两个下拉列表。
一个是Country
,另一个是City
。两者都以"Please Select"
作为默认值。
当用户更改Country
中的值时,City
中正确填充了各个城市。
但是,当用户从网页上的网格中按下edit record
图标时,相应的值会在Country
下拉列表中填充,但City
下拉列值始终保持为{{1} }。
"Please Select"

public onCountryChangeEvent(slectedCountryId): void {
this.populateCityListByCountry(slectedCountryId);
}
private populateCityListByCountry(countryId: Number) {
var city: City = new City();
city.cityId = AppConstants.PLEASE_SELECT_VAL;
city.cityName = AppConstants.PLEASE_SELECT_STR;
const cityCombo: FormControl = (<any>this.myForm).controls.cityId;
if(AppUtility.isEmpty(countryId)){
this.cityList=[];
this.cityList.unshift(city);
cityCombo.reset();
} else {
this.listingService.getCityListByCountry(countryId)
.subscribe(
restData => {
if(AppUtility.isEmpty(restData)){
this.cityList=[];
this.cityId=null;
this.city=null;
}
else{
this.cityList = restData;
if(!AppUtility.isEmptyArray(this.cityList)){
if(!this.isEditing){
this.cityId = this.cityList[0].cityId;
this.city=this.cityList[0].cityName;
}
}
}
this.cityList.unshift(city);
},
error => {this.errorMessage = <any>error;},
()=> {
cityCombo.reset();
}
);
}
}
&#13;