angular 2 dynamically validate multiple forms together and apart -


i'm building angular 2 page have dynamic amount of forms. (the user can add elements each have form). right i've got 1 big form loops on elements , adds fields accordingly. way can validate every field. add controls show user element still has invalid fields. think done best giving each element it's own form cna validate individually. problem i'm not sure how create dynamic references. maybe should looking validating specific fields instead?

my current code looks little this:

<form *ngif="ready" (ngsubmit)="formsubmit()" id="ngform" #form="ngform">     <ng-container *ngfor="let element of elements">         form fields .....     </ng-container>     <button class="btn primary-button [disabled]="!form.form.valid">submit</button </form> 

so thought needed more this:

<ng-container *ngfor="let element of elements">     <button [class.valid]="#{{specific form name??}}.valid" </ng-container>  <ng-container *ngfor="let element of elements">     <form (ngsubmit)="formsubmit()" id="ngform" #{{specific form name??}}="ngform">         form fields .....     </form> </ng-container>  <button class="btn primary-button [disabled]="{{all forms?}}.valid">submit</button 

however found #{{some var}} won't work reference. don't think above possible (correct me if wrong). have found documentation dynamic forms /formgroups dynamic fields none of documentation includes dynamic amount of forms.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -