Good afternoon, I'm doing that when doing tap on a Select call a function that through http is completed an Array with the values that will then run through the * ngFor, the problem is that pressing the Select the first time does not it reaches to load the values, but in the second time that it presses it already loads the list correctly, I suppose that it is because the array that will travel the ngFor still not filled, for that reason I would like to make the ngFor wait for the function options () Is it over, how can I do it?
HTML:
<div *ngIf="item.idTipo=='7'" on-tap="opciones(item.idPregunta)">
<ion-item class="respuesta">
<ion-select [(ngModel)]="select" okText="Seleccionar" cancelText="Cancelar">
<ion-option *ngFor="let opcion of Opciones[item.idPregunta]" [value]="opcion.nombreOpcion">{{opcion.nombreOpcion}}</ion-option>
</ion-select>
</ion-item>
</div>
TS:
opciones(reciboidPregunta){
//recibo el id de la pregunta para cargar las opciones asociadas
this.opcionPost.idPregunta=reciboidPregunta;
this.authServiceProvider.postData(this.opcionPost, 'Opciones')
.then((result) => {
this.responseOpcion = result;
//array que guarda como index a el id de la pregunta
this.Opciones[reciboidPregunta]=this.responseOpcion.opciones;
console.log(this.Opciones);
}, (err) => {
console.log(err);
});
}