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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -