Good.
I am having a problem that I want if the sex is m (Male is selected and if it is f Female according to the value returned from the ajax) here is the code I have
I have this function that is responsible for making the ajax request that returns a json
obtenerConfiguracion(correo: string){
return this.http.get(this.deezerAPI + "/api/Child?correo="+correo).map( res => res.json());
}
Result of the function.
[{"Sexo":"m","Nombre":"Deivis","Color_cabello":"Negro","Color_ojos":"Pardos","Animal_favorito":"Perro","Juguete_favorito":"Pelota Futbol","Termino":"1"}]
Components configuration.html
<ion-content padding>
<form id="registro">
<ion-list text-center>
<ion-item class="container-item">
<ion-label class="label-form" stacked>SEXO</ion-label>
<ion-select name="sexo" [(ngModel)]="sexo">
<ion-option value = "m">Masculino</ion-option>
<ion-option value = "f">Femenino</ion-option>
</ion-select>
</ion-item>
<ion-item class="container-item">
<ion-label class="label-form" stacked>NOMBRE DEL NIÑO/A</ion-label>
<ion-input type="text" [(ngModel)]="nombreApellidos" name="inputNombreApellidos"></ion-input>
</ion-item>
<ion-item class="container-item">
<ion-label class="label-form" stacked>COLOR DE CABELLO</ion-label>
<ion-input type="text" [(ngModel)]="colorCabello" name="colorCabello"></ion-input>
</ion-item>
<ion-item class="container-item">
<ion-label class="label-form" stacked>COLOR DE OJOS</ion-label>
<ion-input type="text" [(ngModel)]="colorOjos" name="colorOjos"></ion-input>
</ion-item>
<ion-item class="container-item">
<ion-label class="label-form" stacked>ANIMAL FAVORITO</ion-label>
<ion-input type="text" [(ngModel)]="animalFavorito" name="animalFavorito"></ion-input>
</ion-item>
<ion-item class="container-item">
<ion-label class="label-form" stacked>JUGUETE FAVORITO</ion-label>
<ion-input type="text" [(ngModel)]="jugueteFavorito" name="jugueteFavorito"></ion-input>
</ion-item>
<ion-item>
<ion-label>He leído y aceptado los términos y condiciones</ion-label>
<ion-checkbox></ion-checkbox>
</ion-item>
<button ion-button class="btn-img-fondo" (click)="registroConfiguracion()" >GUARDAR</button>
</ion-list>
</form>
</ion-content>
configuration.ts
ionViewDidLoad() {
let loader = this.loadingCtrl.create({
content: "Cargando..."
});
loader.present();
this.storage.get('correo').then((val) => {
if(val != "" && val != undefined){
this.usuarios.obtenerConfiguracion(val)
.subscribe(detalles => {
detalles.map(especifico => {
if(especifico.Sexo != "0" && especifico.Nombre != "0" && especifico.Color_cabello != "0" && especifico.Animal_favorito != "0" && especifico.Juguete_favorito != "0"){
//aquí lleno los input con los valores retornados del json,
//y quiero que si el sexo es m en el select se muestre
// seleccionado Masculino
this.nombreApellidos = especifico.Nombre;
this.animalFavorito = especifico.Animal_favorito;
this.jugueteFavorito = especifico.Juguete_favorito;
this.colorCabello = especifico.Color_cabello;
this.colorOjos = especifico.Color_ojos;
this.edita = "1";
}
else
this.edita = "0";
loader.dismissAll();
})
});
}
});
}
Thank you very much in advance.
Sorry, everything was in that I was missing the following line of code