diff --git a/src/app/sidebar/sidebar.component.html b/src/app/sidebar/sidebar.component.html index 2ef6204..8595b2a 100644 --- a/src/app/sidebar/sidebar.component.html +++ b/src/app/sidebar/sidebar.component.html @@ -2,25 +2,25 @@

Mi compra

-
- ... +
+ ...
-

Galleta oreo x 199 gs Chocolate

-

COD: 1234567

+

{{prod.desc}}

+

COD: {{prod.cod}}

- {{90 | currency}} + {{prod.precio | currency}}
- - + +
- - - + + +
diff --git a/src/app/sidebar/sidebar.component.ts b/src/app/sidebar/sidebar.component.ts index 60de369..d97f7bd 100644 --- a/src/app/sidebar/sidebar.component.ts +++ b/src/app/sidebar/sidebar.component.ts @@ -7,9 +7,84 @@ import { Component, OnInit } from '@angular/core'; }) export class SidebarComponent implements OnInit { + private cont: number = 1; + private min: number = 1; + private max: number =50; + + private productos = [ + { + "id": 1, + "desc": "Galletas Oreo", + "cod": 225412, + "precio": 15, + "img": "./assets/descarga.jpg", + "cantidad": 1 + }, + { + "id": 2, + "desc": "Coca cola 500ml", + "cod": 512632, + "precio": 40, + "img": "./assets/descarga.jpg", + "cantidad": 1 + }, + { + "id": 3, + "desc": "Pancho grande", + "cod": 775987, + "precio": 45, + "img": "./assets/descarga.jpg", + "cantidad": 1 + } + ]; + constructor() { } ngOnInit() { + this.getProductosCarrito(); + } + + getProductosCarrito(){ + return this.productos; + + } + + public aumentarContador(cant){ + console.log("llego"); + for (const i of this.productos) { + if (cant === this.max) { + return i.cantidad; + } else{ + ++i.cantidad + return i.cantidad; + } + } + // if (this.cont === this.max) { + // this.cont; + // return this.cont; + // } else { + // ++this.cont; + // return this.cont; + // } + + } + + decrementarContador(){ + if (this.cont === this.min) { + this.cont; + return this.cont; + } else { + --this.cont; + return this.cont; + } } + deleteProducto(index){ + for (let i = 0; i < this.productos.length; i++) + if (i === index) { + this.productos.splice(i,1); + return this.productos ; + } + + } }