Commit aaaac8e780132f660960752b592259b2e109d156

Authored by Jose Pinto
1 parent 71bdf1c374
Exists in master and in 1 other branch develop

alert si no encuentra el domicilio

Showing 1 changed file with 12 additions and 7 deletions   Show diff stats
src/js/controller.js
... ... @@ -5,8 +5,9 @@ angular.module('focaModalLocalizar')
5 5 '$uibModalInstance',
6 6 'focaModalLocalizarService',
7 7 'direccion',
  8 + 'focaModalService',
8 9 function($scope, $uibModalInstance,
9   - focaModalLocalizarService, direccion) {
  10 + focaModalLocalizarService, direccion, focaModalService) {
10 11  
11 12 $scope.latitud = -32.89214159952345;
12 13 $scope.longitud = -68.84572999101856;
... ... @@ -21,12 +22,16 @@ angular.module('focaModalLocalizar')
21 22 format: 'json'
22 23 })
23 24 .then(function(res) {
24   - $scope.latitud = res.data[0].lat;
25   - $scope.longitud = res.data[0].lon;
26   - $scope.$broadcast('moveMap', {
27   - latitud: $scope.latitud,
28   - longitud: $scope.longitud
29   - });
  25 + if(res.data.length) {
  26 + $scope.latitud = res.data[0].lat;
  27 + $scope.longitud = res.data[0].lon;
  28 + $scope.$broadcast('moveMap', {
  29 + latitud: $scope.latitud,
  30 + longitud: $scope.longitud
  31 + });
  32 + }else {
  33 + focaModalService.alert('No se pudo localizar el domicilio');
  34 + }
30 35 });
31 36 }
32 37