Javascript 购物车中的价格也应该更新,因为我增加了产品的数量
我目前正在开发Angular 8应用程序。我想根据购物车中的物品数量增加购物车中的总金额。但目前的情况是,当我增加数量时,购物车中的价格保持不变。 任何帮助都将不胜感激。 谢谢大家! 以下是进一步帮助的图片。 我的HTML代码Javascript 购物车中的价格也应该更新,因为我增加了产品的数量,javascript,html,angular,typescript,angular8,Javascript,Html,Angular,Typescript,Angular8,我目前正在开发Angular 8应用程序。我想根据购物车中的物品数量增加购物车中的总金额。但目前的情况是,当我增加数量时,购物车中的价格保持不变。 任何帮助都将不胜感激。 谢谢大家! 以下是进一步帮助的图片。 我的HTML代码 <div class="modal-footer padding-10"> <a href="javascript:void(0);" (click)="addToCart(filte
<div class="modal-footer padding-10">
<a href="javascript:void(0);" (click)="addToCart(filteredRecipe,'isExtra')"
class="btn-second btn-submit">Add to Cart
<span *ngIf="recipeTotal!=0">{{recipeTotal | currency :'GBP':'symbol':'1.2-2'}}</span>
</a>
</div>
<div class="u-line">
<div class="product-quantity padding-10"><span class="text-light-black fw-700 fs-16">Quantity</span>
<div class="input-group quantity">
<div class="input-group-append">
<button (click)="quantityControl('-')" class="minus-btn" type="button" name="button">
<i class="fas fa-minus"></i>
</button>
</div>
<input type="text" class="text-center" [(ngModel)]="quantity" name="quantity" value="1" style="font-size: 18px; font-weight: bold;">
<div class="input-group-prepend">
<button (click)="quantityControl('+')" class="plus-btn" type="button" name="button"><i
class="fas fa-plus"></i>
</button>
</div>
</div>
</div>
</div>
quantityControl(flag) {
if (flag == '+') {
this.quantity = this.quantity + 1;
if (this.filteredRecipe.RecipePrice != null) {
this.recipeTotal = this.recipeTotal + this.filteredRecipe.RecipePrice;
}
} else {
if (this.quantity != 1) {
this.quantity = this.quantity - 1;
if (this.filteredRecipe.RecipePrice != null) {
this.recipeTotal = this.recipeTotal - this.filteredRecipe.RecipePrice;
}
}
}
}
哪个变量绑定到html上的总价?“recipeTotal”是绑定到它的变量。我刚刚更新了我的HTML代码,你们可以看到你们可以在stackblitz或plunkr上发布工作的最小代码,这样我们就可以解决它了吗?对我来说似乎是范围问题。我已经在这里共享了我的“html”和“Ts”文件的全部代码。你的stackblitz不起作用。。。