0
有谁知道如何重置“离子选择”的“离子选项”值。我有两个离子选择控件,我希望我的第一个离子选择(selectedPLocation)更改ionChange上的第二个离子选择(selectedLocation)的值。我能够通过设置空删除选中,但我无法更改selectedLocation的值。有谁知道如何重置我的离子选项的价值?重置(ionChange)上的离子选项值 - 离子2
我目前使用VS2015是我的IDE。
HTML:
<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();
});}
你有什么想要的值更改为?你已经用'* ngFor'设置了这些值,但是你并没有根据任何东西来声明你希望它们改变到什么...... locations数组的另一个属性? – 2017-03-03 19:18:24
我忘了发布我的手稿代码来绑定我的数据抱歉。无论如何,我设法解决我自己的错误非常感谢。 –