Commit f8080ffa5acd1bfc2e24d5b86cf27dd0b0538a67
1 parent
ec06683ada
Exists in
master
and in
1 other branch
Cambio en el servicio.
Showing
3 changed files
with
5 additions
and
9 deletions
Show diff stats
src/app/components/busqueda-productos/busqueda-productos.component.ts
src/app/components/sidebar/sidebar.component.ts
... | ... | @@ -19,14 +19,13 @@ export class SidebarComponent implements OnInit { |
19 | 19 | |
20 | 20 | public productosCarrito: Producto[] = []; |
21 | 21 | |
22 | - constructor(private productoService: ProductoService) { } | |
22 | + constructor(private productoService: ProductoService) { | |
23 | + | |
24 | + this.productosCarrito = this.productoService.productos; | |
25 | + } | |
23 | 26 | |
24 | 27 | ngOnInit() { |
25 | 28 | |
26 | - this.productoService.productosEvent | |
27 | - .subscribe((data: Producto[]) => { | |
28 | - this.productosCarrito = data; | |
29 | - }, (error) => { console.error(error); }) | |
30 | 29 | } |
31 | 30 | |
32 | 31 | getCantidadProductos() { |
src/app/services/producto.service.ts
... | ... | @@ -3,7 +3,6 @@ import { HttpClient } from '@angular/common/http'; |
3 | 3 | import { Observable } from 'rxjs'; |
4 | 4 | import { appSettings } from 'src/etc/AppSettings'; |
5 | 5 | import { Producto } from '../wrappers/producto'; |
6 | -import { EventEmitter } from '@angular/core'; | |
7 | 6 | |
8 | 7 | @Injectable({ |
9 | 8 | providedIn: 'root' |
... | ... | @@ -11,7 +10,6 @@ import { EventEmitter } from '@angular/core'; |
11 | 10 | export class ProductoService { |
12 | 11 | |
13 | 12 | productos : Producto[] = []; |
14 | - productosEvent: EventEmitter<Producto[]> = new EventEmitter(); | |
15 | 13 | |
16 | 14 | constructor(private http: HttpClient) { } |
17 | 15 | |
... | ... | @@ -23,7 +21,6 @@ export class ProductoService { |
23 | 21 | setProductos(producto : Producto){ |
24 | 22 | |
25 | 23 | this.productos.push(producto); |
26 | - this.productosEvent.emit(this.productos); | |
27 | 24 | } |
28 | 25 | |
29 | 26 | } |