I have a bunch of input fields in a *ngFor
loop. The documentation says that template reference variables should be unique. Is there a way to do something like #attendee-{{person.id}}
to make it unique?
<div *ngFor="let person of attendeesList">
<input #attendee [ngModel]="person.name" (blur)="changeName(attendee.value)"/>
</div>
(I know that there is the option of doing (ngModelChange)="changeName($event)"
but there are reasons I need to use blur instead. Specifically, I don't want the model to change until the person is done typing the name and we have validated that the name is not empty and not a duplicate name.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…