Nomad Nomad - 1 year ago 178
AngularJS Question

Property 'find' does not exist on type 'FormGroup'. any

I have simple angular 2 form code is below

<form [formGroup]="myForm" (ngSubmit)="onSubmit()" class="formcss">
<input type="text" formControlName="username"><br><br>
<input id="email" type="text" formControlName="email">
<div *ngIf="myForm.find('email').valid">Invalid Email</div><br><br>
<input type="text" formControlName="password"><br><br>
<input type="text"><br><br>

<button>Add Hobby</button>
<button type="submit" [ngStyle]="{ background:'green'}" [disabled]="!myForm.valid">Submit</button>

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?

Answer Source

find was removed from AbstractControl (super class of FormGroup) in RC6. You should use get instead

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download