confirmacion-carrito.component.ts 1 KB
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;
  }

}