Skip to content

Instantly share code, notes, and snippets.

@AlexanderArmua
Last active April 7, 2017 13:59
Show Gist options
  • Save AlexanderArmua/b181889aa75d77878b9d82d6dcee7c6e to your computer and use it in GitHub Desktop.
Save AlexanderArmua/b181889aa75d77878b9d82d6dcee7c6e to your computer and use it in GitHub Desktop.
TypeScript AngularJs Promise
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