Exercise: The Built-in `NgFor` Directive

Let’s practice working with the `NgFor` directive.

We'll cover the following

Objectives

In this task, we’ll display users like we did in the previous lesson using NgIf. However, this time the users will be stored in the array. We need to display the users in the form of a list while meeting these requirements:

  1. The users have to be displayed using the NgFor directive.
  2. The user should be able to highlight any list item by clicking it.
  3. The users should be displayed in a clear way. The odd and even rows of data should have different backgrounds, for example, light-grey and dark-grey colors.
  4. We should use the trackBy function to improve the performance of the NgFor directive.

Task

Please write the code below:

Get hands-on with 1200+ tech skills courses.