0

I want to generate inputs for form dynamically and I want to know if I can create references dynamically. I want to use references for validate form inputs.

I want to know if I can do something like this:

<div *ngFor="let input in inputs">
     <input type="text" [attr.name]="input.name" class="form-control" required 
       [(ngModel)]="model[input.name]" #input.name="ngModel"
       [ngClass]="{'error_input': (input.name.valid || !input.name.pristine)     
        || form.submitted, 'valid_input': input.name.valid}">
</div>

If you know other method to validate form please let me know. Thanks.

5

0

Browse other questions tagged or ask your own question.