Commit e8b47a55eddf5b6b33777e27924ff8332cda1a90
Exists in
master
ejemplo2
Showing
4 changed files
Show diff stats
index.html
... | ... | @@ -65,6 +65,7 @@ |
65 | 65 | <script src="./node_modules/foca-sqlite/dist/foca-sqlite.min.js"></script> |
66 | 66 | <script src="./src/js/app.js"></script> |
67 | 67 | <script src="./src/js/controller.js"></script> |
68 | + <script src="./src/js/service.js"></script> | |
68 | 69 | <script src="./src/etc/develop.js"></script> |
69 | 70 | </head> |
70 | 71 | <body> |
src/etc/develop.ejemplo.js
src/js/controller.js
... | ... | @@ -3,7 +3,25 @@ angular.module('appWrapperDemo') |
3 | 3 | '$scope', |
4 | 4 | '$rootScope', |
5 | 5 | '$timeout', |
6 | - function($scope, $rootScope, $timeout) { | |
6 | + 'focaSqliteService', | |
7 | + 'API_ENDPOINT', | |
8 | + 'focaModalService', | |
9 | + function($scope, $rootScope, $timeout, focaSqliteService, API_ENDPOINT, focaModalService) { | |
10 | + document.addEventListener('deviceready', function() { | |
11 | + focaSqliteService.openDataBase(); | |
12 | + }); | |
13 | + | |
14 | + if (!API_ENDPOINT.URL) { | |
15 | + API_ENDPOINT.getUrl().then(success, error); | |
16 | + } | |
17 | + | |
18 | + function success(res) { | |
19 | + API_ENDPOINT.setUrl(res.data); | |
20 | + } | |
21 | + function error() { | |
22 | + focaModalService.alert('La terminal no esta configurada correctamente'); | |
23 | + } | |
24 | + | |
7 | 25 | $scope.usarTeclado = false; |
8 | 26 | $rootScope.$broadcast('usarTeclado', false); |
9 | 27 | $scope.mostrarTeclado = false; |
src/js/service.js
... | ... | @@ -0,0 +1,20 @@ |
1 | +angular.module('appWrapperDemo') | |
2 | +.factory('API_ENDPOINT', [ | |
3 | + '$http', | |
4 | + '$localStorage', | |
5 | + 'ENDPOINT_BASE', | |
6 | + function($http, $localStorage, ENDPOINT_BASE) { | |
7 | + | |
8 | + var direccion = ENDPOINT_BASE; | |
9 | + | |
10 | + return { | |
11 | + URL: $localStorage.urlEndPoint, | |
12 | + setUrl: function(url) { | |
13 | + this.URL = url; | |
14 | + $localStorage.urlEndPoint = url; | |
15 | + }, | |
16 | + getUrl: function() { | |
17 | + return $http.get(direccion + '/terminal/consultar'); | |
18 | + } | |
19 | + }; | |
20 | +}]); |