I have this ngFor
:
<ion-card *ngFor="let review of reviews">
<ion-card-content>
{{getUserName(review.user_ID)}}
</ion-card-content>
</ion-card>
I need to show the user name, but to get user name I need to call user service to get the username. The problem is when I try this. The page keeps loading and loading. What is the correct way to call service inside ngFor
?
This is my getUserName method:
getUserName(userId) {
this.userService.loadUserById(userId)
.then(dataUser => {
this.user = dataUser;
});
return this.user;
}
And when I get the object how to access the object property like in HTML? (Example: user.firstName). Thanks.