I have two servince.ts
function
getSessions(): Promise<UserSessionInterface[]> {
return this.sessioAPI.find()
.toPromise()
.then(response => response as UserSessionInterface);
}
getUserDetails(id: string): Promise<any> {
return this.sessioAPI.getUser(id)
.toPromise()
.then(response => response.firstName + ' ' + response.lastName)
.catch(this.handleError);
}
I call them on component.ts
like this
getSessions() {
this._service.getSessions()
.then(result => {
this.results = result;
});
}
getUserDetails(id?: string) {
return this._service.getUserDetails(id)
.then(result => {
console.log('Inside result : ' + result);
this.userName = result;
});
}
getUserName(id: string) {
return this.getUserDetails(id);
}
I know I can do it with single request inside of component and assign the result to global variable.
But, what I want is to call getUserName
function dynamically inside of *ngFor
, and return the result of Promise as string directly.
Thanks in advance.