Below is my template driven form.
I want to get the local reference name (#{{obj.sample_name}}
) in the *ngIf
to show error message. how to achieve this?
<form class="theme-form" name="sample" #sample="ngForm">
<div *ngFor="let obj of items">
<input type="text"
class="form-control"
[(ngModel)]="obj.sampleValue"
name={{obj.sample_name}}
#{{obj.sample_name}}="ngModel"
[range]="[1, 12]">
<p *ngIf="{{obj.sample_name}}.errors?.range">
error message
</p>
<!-- I want the name of the dyanamic form reference here to show errors -->
</div>
</form>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…