Last active
April 7, 2017 13:59
-
-
Save AlexanderArmua/b181889aa75d77878b9d82d6dcee7c6e to your computer and use it in GitHub Desktop.
TypeScript AngularJs Promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public update = (dataID): any => { | |
var deferred = this.$q.defer(); | |
//var promise = deferred.promise; | |
this.services.getDataById(dataID) | |
.then((data) => { | |
deferred.resolve(data); // En caso de ser exitoso retornamos data (falta catch) | |
}); | |
// En caso de solo querer retornar un "exito" | |
deferred.resolve(); | |
return deferred.promise; // Retornamos el objeto promesa | |
}; | |
private buildData = (dataID): void => { | |
this.rowsTable = []; | |
this.update(dataID) | |
.then((rows) => { | |
this.doThings(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment