I am encountering an issue with form validation in my Angular app using ReactiveForms. The error message reads as follows:
Error:
src/app/pages/contact/contact.component.ts(48,32): error TS2339: Property 'assunto' does not exist on type 'FormGroup'. src/app/pages/contact/contact.component.ts(50,57): error TS2339: Property 'assunto' does not exist on type 'FormGroup'. src/app/pages/contact/contact.component.ts(51,30): error TS2339: Property 'nome' does not exist on type 'FormGroup'. src/app/pages/contact/contact.component.ts(52,33): error TS2339: Property 'empresa' does not exist on type 'FormGroup'. src/app/pages/contact/contact.component.ts(53,32): error TS2339: Property 'email' does not exist on type 'FormGroup'. src/app/pages/contact/contact.component.ts(54,34): error TS2339: Property 'telefone' does not exist on type 'FormGroup'.
Contact Component HTML
<form class="col-s4 dados-form" [formGroup]="dadosForm">
<mat-form-field style="width:100%" class="full-width">
<input matInput placeholder="Name" formControlName="nome" required>
<mat-error *ngIf="dadosForm.get('nome').dirty || dadosForm.get('nome').touched">
Please fill in the name field</mat-error>
</mat-form-field> <br>
<mat-form-field style="width:100%" class="full-width">
<input matInput placeholder="Company" formControlName="empresa" required>
<mat-error
*ngIf="dadosForm.get('empresa').dirty || dadosForm.get('empresa').touched">
Please fill in the company field</mat-error>
</mat-form-field> <br>
<mat-form-field style="width:100%" class="full-width">
<input matInput placeholder="E-Mail" formControlName="email" required>
<mat-error
*ngIf="dadosForm.get('email').dirty || dadosForm.get('email').touched">
{{getMailErrorMessage()}}</mat-error>
</mat-form-field> <br>
<mat-form-field style="width:100%" class="full-width">
<input matInput maxlength="15" id="phoneInput" formControlName="telefone" [mask]="phoneMask" placeholder="Contact Number" required />
<mat-error
*ngIf="dadosForm.get('telefone').dirty || dadosForm.get('telefone').touched">
Please fill in the phone number field</mat-error>
</mat-form-field> <br>
<mat-form-field style="width:100%" class="full-width">
<mat-label>Desired Product</mat-label>
<mat-select matInput formControlName="assunto" required>
<mat-optgroup *ngFor="let category of products" [label]="category.key">
<mat-option *ngFor="let product of category.value" [value]="product">
{{product}}
</mat-option>
</mat-optgroup>
</mat-select>
<mat-error
*ngIf="dadosForm.get('assunto').dirty || dadosForm.get('assunto').touched">
Please select a desired product</mat-error>
</mat-form-field><br>
<mat-form-field style="width:100%" class="full-width">
<textarea matInput placeholder="Message" formControlName="mensagem" required></textarea>
<mat-error
*ngIf="dadosForm.get('mensagem').dirty || dadosForm.get('mensagem').touched">
Please fill in the message field</mat-error>
</mat-form-field><br>
<div class="form-buttons">
<button mat-button mat-raised-button id="submitButton" [disabled]="!dadosForm.valid" matTooltip="" color="primary" (click)="sendMail(message)">Send</button>
</div>
</form>
Contact Component Typescript
dataForm = new FormGroup({
nome: new FormControl('', [Validators.required]),
empresa: new FormControl('', [Validators.required]),
email: new FormControl('', [Validators.required, Validators.email]),
telefone: new FormControl('', [Validators.required]),
assunto: new FormControl('', [Validators.required]),
mensagem: new FormControl('', [Validators.required])
});