Commit 6f8c450dc93926f554ae0eb581d9ba234de49364
1 parent
05279636a5
Exists in
master
and in
1 other branch
Arreglo cuando el id de lista es nulo.
Showing
1 changed file
with
10 additions
and
11 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -31,15 +31,14 @@ angular.module('focaBusquedaProductos') |
31 | 31 | $scope.busquedaPress = function (key) { |
32 | 32 | if (key === 13) { |
33 | 33 | $scope.searchLoading = true; |
34 | - if (parametroProducto.idLista > 0) { | |
35 | - focaBusquedaProductosService | |
36 | - .getProductosByIdLista(parametroProducto.idLista, $scope.filters) | |
37 | - .then(function (data) { | |
38 | - llenarDatos(data); | |
39 | - focaBusquedaProductosService.getProductos() | |
40 | - .then(fillAllProductos); | |
41 | - }); | |
42 | - } | |
34 | + focaBusquedaProductosService | |
35 | + .getProductosByIdLista(parseInt(parametroProducto.idLista), $scope.filters) | |
36 | + .then(function (data) { | |
37 | + llenarDatos(data); | |
38 | + focaBusquedaProductosService.getProductos() | |
39 | + .then(fillAllProductos); | |
40 | + }) | |
41 | + .catch(function (e) { console.log(e) }); | |
43 | 42 | } |
44 | 43 | }; |
45 | 44 | function llenarDatos(res) { |
... | ... | @@ -54,7 +53,7 @@ angular.module('focaBusquedaProductos') |
54 | 53 | }; |
55 | 54 | function fillAllProductos(res) { |
56 | 55 | for (var i = 0; i < res.data.length; i++) { |
57 | - var producto = $scope.listaProductos.filter(function(producto) { | |
56 | + var producto = $scope.listaProductos.filter(function (producto) { | |
58 | 57 | return producto.id == res.data[i].id; |
59 | 58 | })[0]; |
60 | 59 | |
... | ... | @@ -74,7 +73,7 @@ angular.module('focaBusquedaProductos') |
74 | 73 | primera(); |
75 | 74 | }; |
76 | 75 | $scope.search = function (pressed) { |
77 | - if ($scope.listaProductos.length > 0) { | |
76 | + if ($scope.listaProductos.length > 0 || $scope.todosProductos.length > 0) { | |
78 | 77 | $scope.filteredProductos = $filter('filter')( |
79 | 78 | ($scope.useAllProducts ? $scope.todosProductos : $scope.listaProductos), |
80 | 79 | { $: $scope.filters } |