angular.module('focaLogin') .controller('focaModalConfiguracionController', [ '$scope', '$uibModalInstance', 'focaLoginService', '$timeout', '$localStorage', function ($scope, $uibModalInstance, focaLoginService, $timeout, $localStorage) { $scope.puntosVenta = []; $scope.impresoras = []; $scope.selectedPuntoVenta = localStorage.pve ? localStorage.pve : null; $scope.selectedImpresora = $localStorage.impresoraPVE ? $localStorage.impresoraPVE : null; $scope.usePlanillaPropia = false; init(); function init() { var promisePuntosVenta = focaLoginService.getAllPuntoVenta(); var promiseImpresoras = focaLoginService.getAllImpresoras(); Promise.all([promisePuntosVenta, promiseImpresoras]) .then(function (res) { $timeout(function () { $scope.puntosVenta = res[0].data; $scope.impresoras = res[1].data; }); }) .catch(function (err) { console.error(err); }); } $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); }; $scope.acept = function () { $localStorage.pve = $scope.selectedPuntoVenta ? parseInt($scope.selectedPuntoVenta) : null; $localStorage.impresoraPVE = $scope.selectedImpresora ? parseInt($scope.selectedImpresora) : null; $scope.cancel(); } } ]);