confirmacion-carrito.component.ts
1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Component, OnInit } from '@angular/core';
import { appSettings } from 'src/etc/AppSettings';
import { Location } from '@angular/common';
import { ProductoService } from 'src/app/services/producto.service';
import { Producto } from 'src/app/wrappers/producto';
@Component({
selector: 'app-confirmacion-carrito',
templateUrl: './confirmacion-carrito.component.html',
styleUrls: ['./confirmacion-carrito.component.scss']
})
export class ConfirmacionCarritoComponent implements OnInit {
productos: Producto[] = [];
total: number = 0;
private apiUrl: string = appSettings.apiUrl;
constructor(
private location: Location,
private productoService: ProductoService
) { }
ngOnInit() {
this.productos = this.productoService.productos;
}
volverPreviousPage() {
this.location.back();
}
getTotal() {
var subTotal = 0;
this.productos.forEach(producto => {
subTotal = subTotal + (producto.PreVen * producto.cantidad);
});
return this.total = subTotal;
}
}