I have simple angular 2 form code is below
<form [formGroup]="myForm" (ngSubmit)="onSubmit()" class="formcss">
Username<br>
<input type="text" formControlName="username"><br><br>
<div>
Email<br>
<input id="email" type="text" formControlName="email">
<div *ngIf="myForm.find('email').valid">Invalid Email</div><br><br>
Password<br>
</div>
<input type="text" formControlName="password"><br><br>
<h3>Hobbies</h3>
<input type="text"><br><br>
<button>Add Hobby</button>
<button type="submit" [ngStyle]="{ background:'green'}" [disabled]="!myForm.valid">Submit</button>
</form>
I am trying to show message "invalid email" is email filed does not pass validator, but getting this error
error_handler.js:45 EXCEPTION: self.context.myForm.find is not a function
I am using final release of angular 2. Any idea?
find was removed from AbstractControl (super class of FormGroup) in RC6. You should use get instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With