Commit 81bae83d2f0b106eaa7f4aaf52601d0c47daff99
1 parent
2fbf7bb9ee
Exists in
master
Pongo imagen generica si el producto no tiene imagen.
Showing
1 changed file
with
10 additions
and
0 deletions
Show diff stats
src/app/components/busqueda-productos/busqueda-productos.component.ts
... | ... | @@ -61,6 +61,8 @@ export class BusquedaProductosComponent implements OnInit { |
61 | 61 | this.productoService.getAll() |
62 | 62 | .subscribe((data: Producto[]) => { |
63 | 63 | |
64 | + this.setProductosSinImagen(data); | |
65 | + | |
64 | 66 | if (this.queMostrar == 'ordenar') { |
65 | 67 | |
66 | 68 | this.categorias.forEach((categoria: Categoria) => { |
... | ... | @@ -127,4 +129,12 @@ export class BusquedaProductosComponent implements OnInit { |
127 | 129 | } |
128 | 130 | |
129 | 131 | } |
132 | + | |
133 | + private setProductosSinImagen(productos: Producto[]) { | |
134 | + | |
135 | + productos.forEach((producto: Producto) => { | |
136 | + producto.imagenes = producto.imagenes.length == 0 ? | |
137 | + [{ imagen: 'noImage.jpg' }] : producto.imagenes; | |
138 | + }) | |
139 | + } | |
130 | 140 | } |