sum = 0;
total_price = 0;
get grandTotal() {
this.total_price = this.quantity * this.product_price;
this.sum += this.total_price;
return this.sum;
}
onSubmit(quantity, product_price){
this.product_price = parseFloat(product_price);
const data = {
quantity,
product_price
};
this.items.push(data);
localStorage.setItem('items', JSON.stringify(this.items));
}
<div> {{ grandTotal | currency:'USD':true }} </div>
<table>
<tr *ngFor="let item of items">
<td>{{item.quantity}} </td>
<td>{{item.product_price | currency:'USD':true }} </td>
</tr>
<tr><td></td><td></td><td></td><td></td><td>Grand Total </td><td>{{ grandTotal | currency:'USD':true }}</td>
</table>--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/3d753321-c8a5-49a0-8838-7e1152e54087o%40googlegroups.com.
@Pipe({name: 'grandtotal'})
export class GrandTotalPipe implements PipeTransform {
sub_total = 0;
product_price = 0;
quantity = 0;
transform(product_price: number, quantity: number, sub_total: number) {
sub_total = product_price * quantity;
sub_total += sub_total;
return sub_total;
}
}
<div>Grand Total {{product_price | grandtotal: quantity : sub_total}}</div><button class="minus-btn" (click)="minus(product)" type="button" name="btn">
<img src="../assets/images/minus.svg" alt="minus" /></button>
<input pattern="^(0|\+?[1-9]\d*)$" class="num" name="int" [value]="product.nullValue" formControlName="int" ng-minlength="0" type="number">
<button class="plus-btn" (click)="plus(product)" type="button" name="btn">I changed the buttons to anchors but it's still submitting via the click function.
--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/ac7e3f4c-a7b6-4e9d-a155-ec21ec729af2o%40googlegroups.com.
Best Regards,
Scott Logsdon, Web Developer
Ser.vi Worldwide LLC USA & Ser.vi BV Europe
Email: sc...@ser.vi
I did that already but thanks Bastien anyway.
--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/15fc855e-134e-4db3-9c61-1573413c7e4do%40googlegroups.com.
On Mon, Jul 20, 2020 at 9:58 PM Maureen Moore <maka...@gmail.com> wrote:
I added $event.preventDefault(); to the plus function but it's still submitting the quantity.
--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/9f482b6f-500e-470d-bbed-82132029f5e6o%40googlegroups.com.
I added $event.preventDefault(); to the plus function but it's still submitting the quantity.