如何获得 ion-select 的值?我的值仅在我单击该字段时出现

How to get value of a ion-select ? My value only appear when I click on the field

我用 ionic 开发了一个移动应用程序,但 ion-select 标签有问题。 ion-select 值似乎没有加载,直到我点击它。

<ion-item>
    <ion-label position="stacked" style="color: darkgrey">Etat intervention {{liste[0].id_etat_intervention}} - {{etat_select}}</ion-label>
    <ion-select okText="OK" cancelText="Annuler" [value]="liste[0].id_etat_intervention">
        <ion-select-option *ngFor="let etat of etats_intervention" [value]="etat.id" >{{etat.id}} {{etat.libelle}}</ion-select-option>
    </ion-select>
</ion-item>

在我的 ts 文件中:

await this.dbProvider.getEtatsIntervention().then((data) => {
    this.etats_intervention = data;
});

在我的提供商文件中:

getEtatsIntervention () {
        const req = 'SELECT id, libelle FROM etat_intervention ORDER BY libelle ASC ;';

        return this.database.executeSql(req, []).then (result => {
            const infos = [];
            if (result.rows.length > 0) {
                for (let i = 0; i < result.rows.length; i++) {
                    infos.push({
                        id: result.rows.item(i).id,
                        libelle: result.rows.item(i).libelle});
                }
            }
            return infos;
        }).catch(e => console.log('erreur database.getEtatsIntervention() ' + e.error));
    }

并且在加载表单时以相同的方式恢复值'liste[0].id_etat_intervention'

这里发生了什么:

When the form is load

When I click on the field

我尝试了我遇到的一切... 感谢您的帮助!

我找到了解决方案:

<ion-item>
    <ion-label position="stacked" style="color: darkgrey">Etat intervention</ion-label>
    <ion-select okText="OK" cancelText="Annuler" [selectedText]="etat_select" (ionChange)="onChangeEtat($event)">
        <ion-select-option *ngFor="let etat of etats_intervention" [value]="etat.libelle">{{etat.libelle}}</ion-select-option><!-- [value]="etat.id"  -->
    </ion-select>
</ion-item>


onChangeEtat(value) {
    this.etat_select = value.target.value;
}

getEtat() {
    for (const i in this.etats_intervention) {
        if (this.etats_intervention[i].id === this.liste[0].id_etat_intervention) {
            this.etat_select = this.etats_intervention[i].libelle;
        }
    }
}