- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Angular 应用程序,我在通过 ReactiveForms 进行表单验证时遇到了一些问题,我遇到了以下错误:
ng 服务错误:
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="Nome" formControlName="nome" required>
<mat-error *ngIf="dadosForm.get('nome').dirty || dadosForm.get('nome').touched">
O campo nome deve ser preenchido</mat-error>
</mat-form-field> <br>
<mat-form-field style="width:100%" class="full-width">
<input matInput placeholder="Empresa" formControlName="empresa" required>
<mat-error
*ngIf="dadosForm.get('empresa').dirty || dadosForm.get('empresa').touched">
O campo empresa deve ser preenchido</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="Telefone para Contato" required />
<mat-error
*ngIf="dadosForm.get('telefone').dirty || dadosForm.get('telefone').touched">
O campo telefone deve ser preenchido</mat-error>
</mat-form-field> <br>
<mat-form-field style="width:100%" class="full-width">
<mat-label>Produto Desejado</mat-label>
<mat-select matInput formControlName="assunto" required>
<mat-optgroup *ngFor="let categoria of produtos" [label]="categoria.key">
<mat-option *ngFor="let produto of categoria.value" [value]="produto">
{{produto}}
</mat-option>
</mat-optgroup>
</mat-select>
<mat-error
*ngIf="dadosForm.get('assunto').dirty || dadosForm.get('assunto').touched">
O campo assunto deve ser preenchido</mat-error>
</mat-form-field><br>
<mat-form-field style="width:100%" class="full-width">
<textarea matInput placeholder="Mensagem" formControlName="mensagem" required></textarea>
<mat-error
*ngIf="dadosForm.get('mensagem').dirty || dadosForm.get('mensagem').touched">
O campo mensagem deve ser preenchido</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(mensagem)">Enviar</button>
</div>
</form>
contact.component.ts
dadosForm = 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])
});
最佳答案
<div *ngIf="f.name.invalid && f.name.touched">
<small class="text-danger" *ngIf="f.name.errors?.required">Please enter the name!</small>
</div>
在ts文件中
get f() { return this.form.controls; }
关于angular - 类型 'nome' 上不存在属性 'FormGroup',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56169902/
我有问题,需要帮助 这是我的查询 ALTER VIEW contrato AS SELECT formando.nome, formando.bicc, formando.nif, formando.
我有一个 Angular 应用程序,我在通过 ReactiveForms 进行表单验证时遇到了一些问题,我遇到了以下错误: ng 服务错误: src/app/pages/contact/contact
我有一个 Angular 应用程序,我在通过 ReactiveForms 进行表单验证时遇到了一些问题,我遇到了以下错误: ng 服务错误: src/app/pages/contact/contact
为什么这段代码只写了第一次和最后一次出现的 nome、cognome 和 cf? #include #include #include typedef struct data{ char
这个问题在这里已经有了答案: Difference between getDefaultSharedPreferences and getSharedPreferences (6 个答案) 关闭 8
我在 Jenkins 上运行 gradle 构建时遇到问题:Gradle 版本是 https://services.gradle.org/distributions/gradle-2.14.1-bin
我是一名优秀的程序员,十分优秀!