Help needed with adding negative numbers in an array. When trying to add or subtract, no value is displayed. The problem seems to arise when using array methods. I am new to arrays, could someone please point out where my code is incorrect? Here is my demo code on StackBlitz.
HTML
<div class="p-buttom">
<ion-button expand="full" color="dark" (click)="add()">Add</ion-button>
</div>
<div class="size-bg" *ngFor="let num of size;let i = index">
<span style="display: flex;">
<ion-col>
<ion-item lines="none" size="6" class="border">
<ion-label position="stacked">weight</ion-label>
<ion-input type="text" class="uppercase" [(ngModel)]="data.weight[i]" name="menuCode"></ion-input>
</ion-item>
</ion-col>
<ion-col>
<ion-item lines="none" size="6" class="border">
<ion-label position="stacked">Price</ion-label>
<ion-input type="text" class="uppercase" [(ngModel)]="data.price[i]" name="menuCode"></ion-input>
</ion-item>
</ion-col>
</span>
<ion-label style="color: black; ">quantity</ion-label>
<ion-col size="12">
<div class="add-quatity">
<ion-button class="removeBtn no-padding " fill="solid " slot="end" style="color: black;" (click)="MinusMinOrder() ">
-
</ion-button>
<ion-input class="itemCount no-padding" name="quantity" (keypress)="numberOnlyValidation($event)" [(ngModel)]="data.quantity[i]" value="{{addQuantityP[i]}}"></ion-input>
<ion-button class="addBtn no-padding " fill="solid " slot="end" style="color: black;" (click)="addQuantity(i) ">
+
</ion-button>
</div>
</ion-col>
<div>
<ion-button expand="full" color="danger" *ngIf="i >0" (click)="remove(i)">Delete</ion-button>
</div>
</div>
<div>
<ion-button fill="solid " slot="end" (click)="addMenu() ">Submit</ion-button>
</div>
Component
add(){
this.size.push('');
}
remove(index) {
this.size.splice(index,1)
}
minusQuantity(i){
console.log(i);
this.data.quantity[i]--;
console.log(this.data.quantity[i]--);
}
addQuantity(i){
console.log(i);
this.data.quantity[i]++;
console.log(this.data.quantity[i]++);
}
addMenu(){
console.log(this.data);
}
Thanks in advance