changeQty(item, varia, valor){
let eMax = 0;
for (var i = 0; i < this.selectedVariation.length; ++i) {
if (this.selectedVariation[i].idPV == item.idPV) {
// console.log(this.selectedVariation[i]);
eMax++;
}
}
if (valor > 0) {
if (eMax < varia.eMax) {
this.selectedVariation.push(item);
}else{
console.log('Número máximo excedido');
}
}else if (valor < 0){
let index = this.selectedVariation.findIndex(indice => indice.idPVI === item.idPVI);
// console.log(index);
if (index >= 0) {
this.selectedVariation.splice(index, 1);
}
}
console.log(this.selectedVariation);
}
I would like to display the number of items entered, which in this case are pizza flavors.
<ion-list *ngIf="varia.eMax > 1">
<ng-container *ngFor="let item of itensVaria">
<ion-item class="compact" *ngIf="item.idPV == varia.idPV">
<ion-row no-padding>
<ion-col col-7 style="text-align: left;">
<h2 class="h2">{{item.descri}}</h2>
<strong class="danger">+ R$ {{money(item.preco)}}</strong>
</ion-col>
<ion-col col-5>
<button ion-button icon-only clear color="danger" [disabled]="!saborJaAdicionado(item)" (click)="changeQty(item, varia, -1)">
<ion-icon name="remove-circle"></ion-icon>
</button>
<!-- <button ion-button clear color="danger"> qtd do item </button> -->
<button ion-button icon-only clear color="danger" [disabled]="saborJaAdicionado(item)" (click)="changeQty(item, varia, 1)">
<ion-icon name="add-circle"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-item>
</ng-container>
</ion-list>