Angular 2 Form "cannot Find Control"
Solution 1:
This may not be the answer to the original question, but this may be useful if you jumped here from google.
You need to check these things.
You must have a "
name
" attribute for all the controls which has[ngModel]
If you exclude some fields from validation, then add
[ngModelOptions]="{standalone: true}"
(remember the first rule, still you need a "name")Make sure you have
formControlName
attribute for the controls that you are going to validate. (remember the first rule)
Solution 2:
I tried to create new FormGroup in my component. I've imported ReactiveFormsModule from angular/forms and added to app.module.ts imports.
but I was getting Cannot find name 'FormGroup' and Cannot find name 'FormControl' errors
Here is my component
exportclassSignupFormComponent {
form1 = newFormGroup({
username: newFormControl(),
password: newFormControl()
});
}
Adding the below import statement in component resolved my issue.
import { FormGroup, FormControl } from'@angular/forms';
Not the answer to your question but Posting as this might help someone who faces same error.
Post a Comment for "Angular 2 Form "cannot Find Control""