Commit a410b1873cf6e9cef731c3839de8bb8a1e7732f8
1 parent
a21e58e364
Exists in
master
controlo cuando idLista viene null o undefined
Showing
1 changed file
with
16 additions
and
6 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -7,12 +7,22 @@ angular.module('focaBusquedaProductos') |
7 | 7 | 'idLista', |
8 | 8 | 'focaBusquedaProductosService', |
9 | 9 | function($filter, $scope, $uibModalInstance, idLista, focaBusquedaProductosService) { |
10 | - focaBusquedaProductosService.getProductosByIdLista(idLista).then( | |
11 | - function(res) { | |
12 | - $scope.productos = res.data; | |
13 | - $scope.search(); | |
14 | - } | |
15 | - ); | |
10 | + if(idLista) { | |
11 | + focaBusquedaProductosService.getProductosByIdLista(idLista).then( | |
12 | + function(res) { | |
13 | + $scope.productos = res.data; | |
14 | + $scope.search(); | |
15 | + } | |
16 | + ); | |
17 | + } else { | |
18 | + focaBusquedaProductosService.getProductos().then( | |
19 | + function(res) { | |
20 | + $scope.productos = res.data; | |
21 | + $scope.search(); | |
22 | + } | |
23 | + ); | |
24 | + } | |
25 | + | |
16 | 26 | |
17 | 27 | // pagination |
18 | 28 | $scope.numPerPage = 10; |