I\'m looking at this example from Angular\'s docs for $q
but I think this probably applies to promises in general. The example below is copied verbatim from the
Maybe this small Typescript code example will help.
private getAccount(id: Id) : Account {
let account = Account.empty();
this.repository.get(id)
.then(res => account = res)
.catch(e => Notices.results(e));
return account;
}
Here the repository.get(id)
returns a Promise
. I assign it to the variable account
within the then
statement.