#javascript #html #angular #typescript #angular8
#javascript #HTML #angular #машинопись #angular8
Вопрос:
В настоящее время я работаю над приложением Angular 8. Я хотел увеличить общую сумму в корзине по отношению к количеству товаров в корзине. Но в настоящее время происходит то, что когда я увеличиваю количество, цена в корзине остается неизменной. Любая помощь была бы очень признательна. Спасибо!
Вот фотографии для дополнительной помощи.
Мой HTML-код
<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>
Мой код TS
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;
}
}
}
}
Комментарии:
1. какая переменная привязана к общей цене в html?
2. ‘recipeTotal’ — это переменная, привязанная к нему. Я только что обновил свой HTML-код, который вы можете видеть
3. можете ли вы опубликовать рабочий минимальный код на stackblitz или plunkr, чтобы мы могли его отсортировать? для меня это похоже на проблему с областью.
4. Я поделился полным кодом моего файла ‘html’ и ‘Ts’ здесь stackblitz.com/edit/angular-ivy-47aqjw?file=src/app /…
5. Ваш stackblitz не работает…