9.4: Displaying Followers in Followers Component
This component will be very similar to our MemberListComponent.
We'll call the getUsers() method from our UserService - but, this time we'll pass in query parameters to only return Followers or Followees.
We'll display paged results similarly, but instead of sorting and filtering filters - we'll just have a choice between Followers and Followees.
Updating UserService
First, we'll add a parameter for followParam:
getUsers(page?, itemsPerPage?, userParams?, followParam?): Observable<PaginatedResult<User[]>> {Next, we'll add two conditionals to check the value of the followParam:
if (followParam === 'Followers') {
params = params.append('Followers', 'true');
}
if (followParam === 'Followees') {
params = params.append('Followees', 'true');
}Add Followers Resolver
In the SPA/src/app/resolvers folder, add a new file called followers.resolver.ts.
This will be very similar to member-list.resolver.ts
We'll add another property called followParam and set a default value of "Followers".
We'll pass in a null value for userParams since we don't need to send any. Then we'll pass in our followParam.
In app.module.ts - import the resolver and add it to the providers array:
Next, we'll add it to the routes.ts file:
Update FollowersComponent
Update the followers.component.ts file to the following:
This is all very similar to what we've done before.
Update FollowersComponent Template
This will also be similar to the MemberListComponent:
Finally, we'll copy the same styling over from the MemberListComponent to our followers.component.scss file:
It should work! Open the browser and test:

Last updated