Asp.net 重置(离子更改)-离子2上的离子选项值
有人知道如何重置“离子选择”的“离子选项”值吗。我有两个离子选择控件,我希望我的第一个离子选择(selectedPLocation)在ionChange上更改我的第二个离子选择(selectedLocation)的值。我可以通过设置null来删除selected,但无法更改selectedLocation的值。有人知道如何重置我的离子选项的值吗 我目前正在使用VS2015作为我的IDE HTML:Asp.net 重置(离子更改)-离子2上的离子选项值,asp.net,html,typescript,ionic2,Asp.net,Html,Typescript,Ionic2,有人知道如何重置“离子选择”的“离子选项”值吗。我有两个离子选择控件,我希望我的第一个离子选择(selectedPLocation)在ionChange上更改我的第二个离子选择(selectedLocation)的值。我可以通过设置null来删除selected,但无法更改selectedLocation的值。有人知道如何重置我的离子选项的值吗 我目前正在使用VS2015作为我的IDE HTML: 我解决了自己的错误,这是由于我的Typescript代码调用了我的web服务API(GetLoca
我解决了自己的错误,这是由于我的Typescript代码调用了我的web服务API(GetLocation) 以前的TypeScript代码: 正确的打字脚本代码:
您希望将值更改为什么?您已经使用
*ngFor
设置了值,但您没有根据任何内容说明要将其更改为什么。。。locations数组的另一个属性?我忘了发布我的Typescript代码来绑定我的数据。很抱歉。无论如何,我确实解决了我自己的错误,非常感谢。
<ion-list>
<ion-item>
<ion-label>Parent Location</ion-label>
<ion-select [(ngModel)]="selectedPLocation" (ionChange)="loadLocation()">
<ion-option *ngFor="let parentLocation of parentLocations; let i=index" [value]="parentLocation.Key">{{parentLocation.Id}}</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Location</ion-label>
<ion-select [(ngModel)]="selectedLocation">
<ion-option id="locationID" *ngFor="let location of locations; let i=index" [value]="location.Key">{{location.Id}}</ion-option>
</ion-select>
</ion-item>
</ion-list>
public loadLocation() {
let loader = this.loadingCtrl.create({
content: "Please wait..."
});
loader.present();
this.selectedLocation = null; //Reset selected value only
this.locations = null; //Tried this but can't seem to reset the values
this.locationService.GetLocations(this.global.getApiUrl(), this.selectedSite, this.selectedPLocation).then(data => {
loader.dismiss();
this.locations = data;
}).catch((err) => {
loader.dismiss();
let alert = this.alertCtrl.create({
title: 'Error',
subTitle: err,
buttons: ['OK']
});
alert.present();
});}
public GetLocations(apiUrl, siteKey, pLocationKey) {
return new Promise((resolve, reject) => {
this.http.get(apiUrl + "site/" + siteKey + "/location/" + pLocationKey)
.map(res => res.json())
.subscribe(data => {
this.Locations = data; //Error Here
resolve(this.Locations);; //Error Here
},
err => {
reject(err);
});
});
}
public GetLocations(apiUrl, siteKey, pLocationKey){
return new Promise((resolve, reject) => {
this.http.get(apiUrl + "site/" + siteKey + "/location/" + pLocationKey)
.map(res => res.json())
.subscribe(data => {
resolve(data); //Corrected
},
err =>{
reject(err);
});
});
}