How can I associate labels with form fields outside them in Angular?
问题 Let's say I'm creating labels and form fields in a *ngFor loop like this: app.component.ts export class AppComponent { items = ['aaa', 'bbbbbb', 'ccccccccc'] } app.component.html <div class='form'> <ng-container *ngFor="let item of items"> <label>{{item|uppercase}}:</label> <input [value]="item"/> </ng-container> </div> (See it on StackBlitz: https://stackblitz.com/edit/angular-ptwq6t) Is there a way to cleanly associate these "dynamic" labels and inputs with one another? If I do: <label for=