angular-training-slides icon indicating copy to clipboard operation
angular-training-slides copied to clipboard

The HTML "id" Attribute Shouldn't be Used Inside a `NgFor` Loop

Open barretodavid opened this issue 8 years ago • 0 comments

In the slide number 33 (Make Items Findable) we are suggesting students to use the HTML attribute "id" inside the for loop for easier testing like this:

<p *ngFor="let item of thingsToDo; let i = index" id="{{i}}">({{i}}) {{item}}</p>

In general I think this is not a good practice because the id should be unique in a page and a page might have multiple components, each with its own NgFor creating duplications. Even using strong identifiers like uuid from a database is not guarantee to avoid collisions because we might still have two components showing the same list of items but with different "display".

barretodavid avatar Apr 21 '17 18:04 barretodavid