1
Gentlemen, I’m making this mistake by running my registration form..
ERROR Typeerror: Cannot read Property 'name' of Undefined at Forms.js:3282 at Forms.js:3222 at Array.foreach () At Formgroup.push.. /node_modules/@angular/Forms/fesm5/Forms.js.Formgroup. _forEachChild (Forms.js:3222) At Formgroup.push.. /node_modules/@angular/Forms/fesm5/Forms.js.Formgroup. _checkAllValuesPresent (Forms.js:3281) At Formgroup.push.. /node_modules/@angular/Forms/fesm5/Forms.js.Formgroup.setValue (Forms.js:3071) at ContactformComponent.push.. /src/app/contactform/contactform.component.ts.ContactformComponent.ngOnInit (contactform.component.ts:57) checkAndUpdateDirectiveInline (core.js:9250) checkat AndUpdateNodeInline (core.js:10514) checkat AndUpdateNode (core.js:10476)
Follows my code:
  contactFrm: FormGroup;
  constructor(@Inject(MAT_DIALOG_DATA) public data: any,
                     private fb: FormBuilder,
                     private _contactService: ContactService,
                     public dialogRef: MatDialogRef<ContactlistComponent>) {}  
ngOnInit() {
    // built contact form
    this.contactFrm = this.fb.group({
      //id: [''],
      name:  [''],
      email: ['', [Validators.required, Validators.email]],
      gender: ['', [Validators.required]],
      birth: ['', [Validators.required]],
      techno: ['', [Validators.required]],
      message: ['', [Validators.required]]
    });
}
html:
<form  (ngSubmit)="onSubmit(contactFrm)"  [formGroup]="contactFrm">
    <h2>{{data.modalTitle}}</h2>
    <div>
        <mat-form-field appearance="outline">
        <mat-label>Name</mat-label>
        <input type="text" matInput placeholder="Name" name="name" formControlName="name">
        <!-- <mat-icon matSuffix>sentiment_very_satisfied</mat-icon> -->
        <!-- <mat-hint>Hint</mat-hint> -->
        <mat-error *ngIf="formErrors.name">
          {{ formErrors.name }}
        </mat-error>
      </mat-form-field>
    </div>
</form>
I’m trying to make an example of this website.
opa, I think I’m missing putting "ngModel" in your name input. Can you see if this is it?
– Rhadamez Gindri Hercilio
not if that’s it, because in the example it doesn’t use.. I’m running Angular 6
– Henrique Abreu