I am creating a card creator, where the user places the number of cards and then the value of each card. The problem is that, when the user is placing the value of the card, the value drops to another input.
Code:
HTML:
<ion-item>
<ion-label position="floating">Numero de cartões:</ion-label>
<ion-input type="number" (ionChange)="updateNumberOfPointCards($event)"></ion-input>
</ion-item>
<ion-item padding-horizontal *ngFor="let card of pointCards;let i= index">
<ion-label position="floating">Pontos do cartão {{i+1}}:</ion-label>
<ion-input type="number" (ionChange)="updateCardPointsValue($event,i,card)"></ion-input>
</ion-item>
javascript:
pointCards = [];
updateNumberOfPointCards(number){
this.pointCards.length = number.detail.value;
console.log(this.pointCards);
}
updateCardPointsValue(value, cardNumber, cardtest){
console.log("VALOR ",value.detail.value);
console.log("NUMBERO DO CARTÂo", cardNumber);
console.log("CARD TEST", cardtest);
this.pointCards[cardNumber] = value.detail.value;
console.log(this.pointCards);
}
this is what happens when i place a value on the first input:
After placing a value on the first input
After i press enter, the value drops to the second input idk why.
and the console.log of the array is this : (2) ["2", empty]
and then i place as value on the first input, like a 3 and the array gets like this: (2) ["3", empty]