Hello,
I would like to clarify the difference and when to use each of the promising treatment templates:
obj.promessa( parametro ).then( function ( resposta ) {
console.log("Resposta: " + resposta);
}, function ( erro ) {
console.log("Erro: " + erro);
});
and
obj.promessa( parametro ).then( function ( resposta ) {
console.log("Resposta: " + resposta);
}).catch( function ( erro ) {
console.log("Erro: " + erro);
});
Whereas the obj.promess method was something like:
promessa: function( parametro ) {
var deferred = q.defer();
if ( fun_assincrona(parametro) ) {
return deffered.resolve("sucesso");
} else {
return deferred.reject("error");
}
return deferred.promise;
}
Hugs!