I've created a Factory to perform the operations CRUD in a api REST using $ http service to make a user control.
Factory
//Listar..Recuperar ..Inserir ...Editar..{...}
usuarioService.Excluir = function (id) {
var promise = $http({
method: 'DELETE',
url: API_URL.url + '/api/v1/usuario/' + id
})
.then(function (response) {
return response.data;
},
function (response) {
return alert(response.statusText + ' ' + response.data.errors + ' ' + response.data.message);
});
return promise;
};
Controller
//Listar..Recuperar ..Inserir ...Editar..{...}
vm.Excluir = function Excluir() {
usuarioService.Excluir(vm.id).then(function (result) {
$location.path("/usuario");
})
};
How can I capture the response in erro
cases in my controller
?