Skip to content

Instantly share code, notes, and snippets.

@mauroa
Last active September 18, 2015 21:33
Show Gist options
  • Save mauroa/c473488f1603784db71b to your computer and use it in GitHub Desktop.
Save mauroa/c473488f1603784db71b to your computer and use it in GitHub Desktop.
controllers.controller('HomeController', function(filtrosService, httpService) {
var viewModel = this;
viewModel.nombre = 'Antes';
viewModel.especialidades = filtrosService.getEspecialidades();
viewModel.actualizarNombre = function(nombreNuevo){
alert('estoy en actualizar nombre: ' + nombreNuevo);
viewModel.nombre = nombreNuevo;
}
viewModel.getRest = function() {
httpService.getUsuario('22755022', 'M', viewModel.actualizarNombre);
};
});
services.factory('httpService', function($http) {
return {
getUsuario: function(dni, sexo, actualizar) {
alert('DNI: '+ dni + ' Sexo: '+ sexo);
$http.get('http://www.osdepym.com.ar:8080/OSDEPYM_CartillaWeb2/rest/mobile/getAfiliado?dni='+dni+'&sexo='+sexo+'')
.then(function(resp) {
//alert(JSON.stringify(resp));
var nombre = resp.data.afiliadoTO.nombre;
//alert(nombre);
actualizar(nombre);
}, function(err) {
var nombre = 'Error';
alert(JSON.stringify(err));
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment