I'm implementing a feature where the user selects a select
option and is sent to a function that adds to my model.
For some reason, after selecting the option of my select
, the next field of my ngfor
adds up, it reappears if I click on it, everything works normal in the ionic serve, but when I roll the pro build cell, after selecting the select
the field of the other index some.
My code:
resposta: string[] = [""];
saudacao: string = '';
<div>
<ion-row>
<div class="col-8">
<ion-item>
<ion-textarea name="resposta{{i}}" [(ngModel)]="resposta[pergunta.id]" value="{{resposta[pergunta.id]}}" placeholder="Resposta" clearInput></ion-textarea>
</ion-item>
</div>
<div class="col-4">
<a (click)="respondePergunta(i)"><ion-icon class="responderperguntaicon" name="ios-arrow-dropright-circle"></ion-icon></a>
<a (click)="presentActionSheet()"><ion-icon id="maisopcoes" color="primary" name="more"></ion-icon></a>
</div>
</ion-row>
<ion-item>
<ion-label>Resposta Automática</ion-label>
<ion-select (ionChange)="adicionaArrayRespostaAutomatica($event, pergunta.id)">
<ion-option value="Sim, temos no estoque ">Sim, temos no estoque</ion-option>
<ion-option value="Não, não temos no momento ">Não, não temos no momento</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>Inserção Rápida Sistema</ion-label>
<ion-select (ionChange)="adicionaArrayInsercaoRapida($event, pergunta.id)">
<ion-option value="{{saudacao}}">Saudação</ion-option>
</ion-select>
</ion-item>
</div>
My role:
adicionaArrayRespostaAutomatica(event, index){
if(this.resposta[index] == null){
this.resposta[index] = '';
this.resposta[index] = this.resposta[index] + ' ' + event;
}else{
this.resposta[index] = this.resposta[index] + ' ' + event;
}
}
adicionaArrayInsercaoRapida(event,index){
if(this.resposta[index] == null){
this.resposta[index] = '';
this.resposta[index] = this.resposta[index] + ' ' + event;
}else{
this.resposta[index] = event + this.resposta[index];
}
}