Skip to content

Instantly share code, notes, and snippets.

@cgonzalezdai
Created August 31, 2016 06:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgonzalezdai/744e2818ba165a1c247c4b4457d7c351 to your computer and use it in GitHub Desktop.
Save cgonzalezdai/744e2818ba165a1c247c4b4457d7c351 to your computer and use it in GitHub Desktop.
Ejemplo básico de promesa.
var promesa = new Promise (function (resolve, reject) {
//consulta asíncrona angular
$http(consulta).success(function (resp){
// hacemos cosas con la respuesta de la consulta
resolve(true);
}).error(function() {
reject(false);
})
});
promesa.then(function(resp) {
// hacemos cosas despues de obtener la respuesta de la promesa
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment