Commit c69b29e38e504893abe518ecc067015b67a6d5fb
1 parent
ab97fc8d10
Exists in
master
soporta consultas json
Showing
3 changed files
with
13 additions
and
5 deletions
Show diff stats
src/js/controllerModal.js
... | ... | @@ -23,7 +23,12 @@ angular.module('focaModal') |
23 | 23 | $scope.busquedaPress = function(key) { |
24 | 24 | if(key === 13) { |
25 | 25 | $scope.searchLoading = true; |
26 | - focaModalService.getEntidad($scope.filters, parametrosModal.query).then( | |
26 | + focaModalService.getEntidad( | |
27 | + $scope.filters, | |
28 | + parametrosModal.query, | |
29 | + parametrosModal.tipo, | |
30 | + parametrosModal.json | |
31 | + ).then( | |
27 | 32 | function(res) { |
28 | 33 | $scope.searchLoading = false; |
29 | 34 | $scope.primerBusqueda = true; |
src/js/service.js
1 | 1 | angular.module('focaModal') |
2 | - .service('focaModalService', [ | |
2 | + .factory('focaModalService', [ | |
3 | 3 | '$uibModal', 'API_ENDPOINT', '$http', |
4 | 4 | function($uibModal, API_ENDPOINT, $http) { |
5 | 5 | return { |
... | ... | @@ -49,8 +49,12 @@ angular.module('focaModal') |
49 | 49 | } |
50 | 50 | ); |
51 | 51 | }, |
52 | - getEntidad: function(filters, query) { | |
53 | - return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); | |
52 | + getEntidad: function(filters, query, tipo, json) { | |
53 | + if (tipo === 'POST') { | |
54 | + return $http.post(API_ENDPOINT.URL + query, json); | |
55 | + } else { | |
56 | + return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); | |
57 | + } | |
54 | 58 | }, |
55 | 59 | modalFecha: function(titulo) { |
56 | 60 | return $uibModal.open({ |
src/views/foca-modal.html