Imagine having a list of all the users within your system:
allUsers = {
a: {name:'Adam',email:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="39585d5854794d5c4a4d5a56175a56...
f: {name:'fred',email:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e187938485a195849295828ecf82...
}
Now, envision having another list that contains the users involved in a specific project:
usersList = ['a','b','d','f'];
To simplify the process, you can utilize a function that takes a user ID and retrieves additional user details:
getUser(userId){
console.log('Getting User with Id:', userId);
if(allUsers[userId]) return allUsers[userId];
}
However, when utilizing *ngFor to iterate through the users in the list within the template, there seems to be an issue retrieving the complete set of user details:
<tr *ngFor="#userId in usersList" #user="getUser(userId)">
<td>{{user.name}}</td>
</tr>
This method doesn't seem optimal as it calls the getUser function repeatedly. Is there a simpler way to access the userId variable and define it as a local variable?
Feel free to check out this plunker for my current experimentations