HttpClient.get()
and displays them in the template using RxJS and Angular's async
pipe:users$
observable that sends an HTTP GET request to fetch the list of users:async
pipe subscribes to users$
, and the data is automatically rendered when available.@for
loop to asynchronously iterate over users$
.
The async
pipe automatically subscribes to the Observable and updates the DOM when the data arrives.
The track by user.id
ensures efficient DOM updates by uniquely identifying each user using their id
.pipe()
method to process the users$
observable using the map()
operator.map()
operator transforms the incoming array of User[]
.map()
, we first filter
the users and then modify each user’s name.filter
method to filter the users so that only those with an id
greater than 4
are included in the final array.map
method to converts the array of User
in array of names, transforming each user's name to uppercase: