angular / angular/components

[input] Add example of using mat-error with parent formgroup validation

未关闭
#8,513 20 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看
area: material/form-field docs feature help wanted P4
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

**Bug, feature request, or proposal:**
`` doesn't show when I use an email maching validator for emails inputs.

**What is the expected behavior?**
To display the error.

**What is the current behavior?**
No error is displayed

**What are the steps to reproduce?**

Set a custom validator for check if two emails inputs are equals, like this :

```
private matchEmail(AC: AbstractControl) {
return AC.get('mail').value === AC.get('mailconfirm').value ? null : { mailmismatch: true };
}

this.administratifForm = this.fb.group({
(...),
mail: this.fb.control('', [Validators.required, Validators.email]),
mailconfirm: this.fb.control('', [Validators.required]),
(...),
}, {
validator: this.matchEmail,
},
);
```
The template :
```



Ce champ est requis


Les adresses mail ne correspondent pas

```

**Which versions of Angular, Material, OS, TypeScript, browsers are affected?**
Angular 5.0.2, Material 5.0.0-rc0, MacOS Sierra, Firefox

**Additional Information**
**If i replace the `` tag by a `

` tag (or anything else), it's work.**

贡献指南

打开贡献指南

调研方向

该 issue 没有指定任何 repository 文件、测试或文档入口;请先从 inline mat-error 和父级 FormGroup 的复现开始。完成标准是添加一个清晰的已报告验证场景示例,并确认预期错误已显示。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
documentation, frontend
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。