Abdul Mohammed
asked on
Reactive Form Validation - Angular 2 - Unable to pick a formArray's controls which is in the main form.
createNewASLForm is the main FORM
AslAccount - is the formArray
From Mark up -
<div *ngIf="createNewASLForm.ge t('AslAcco unt').get( 'acctNumbe r').touche d " class="alert alert-danger">
Please enter Acct Number
</div>
Tried another
<input class="form-control g-remove-margin-bottom" value="" type="text" formControlName="aslFormNa me" placeholder="ASL Form Name" name ="acctNumber" required>
<div *ngIf="createNewASLForm.co ntrols.Asl Account.co ntrols.['a cctNumber' ].hasError ('required ') && createNewASLForm.controls. AslAccount .controls. ['acctNumb er'].touch ed" class="alert alert-danger">
Please enter Acct Num
</div>
Also need to add an entry for 11 numerical vals only....
Same this works for standalone controls in the main form
<input class="form-control g-remove-margin-bottom" value="" type="text" formControlName="aslFormNa me" placeholder="ASL Form Name" name ="aslFormName" required>
<div *ngIf="createNewASLForm.co ntrols['as lFormName' ].hasError ('required ') && createNewASLForm.controls[ 'aslFormNa me'].touch ed" class="alert alert-danger">Please enter ASL form name</div>
Any help or pointers is appreciated.
Tried this one too...
Used this one too in the markup
<input class="form-control g-remove-margin-bottom" value="" type="text" formControlName="myAcct" required>
<div *ngIf="myForm.get('SomeAcc t').get('m yAcct').to uched " class="alert alert-danger">Please enter Acct Number</div>
Kept throwing errors.
AslAccount - is the formArray
From Mark up -
<div *ngIf="createNewASLForm.ge
Please enter Acct Number
</div>
Tried another
<input class="form-control g-remove-margin-bottom" value="" type="text" formControlName="aslFormNa
<div *ngIf="createNewASLForm.co
Please enter Acct Num
</div>
Also need to add an entry for 11 numerical vals only....
Same this works for standalone controls in the main form
<input class="form-control g-remove-margin-bottom" value="" type="text" formControlName="aslFormNa
<div *ngIf="createNewASLForm.co
Any help or pointers is appreciated.
Tried this one too...
Used this one too in the markup
<input class="form-control g-remove-margin-bottom" value="" type="text" formControlName="myAcct" required>
<div *ngIf="myForm.get('SomeAcc
Kept throwing errors.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER