angular / angular/components

mat-error does not display on submit when fields are added in a FormArray

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

描述

#### Bug, feature request, or proposal:
The `mat-error` directive doesn't display on submit when fields are added in a FormArray. The error is shown when you touch the field. Also when I change the mat-error to a regular div, the div is just being shown.

#### What is the expected behavior?
Show `mat-error` on submit when field is untouched.

#### What is the current behavior?
Does not show `mat-error` on submit when field is untouched.

#### What are the steps to reproduce?
Repro: https://angular-material2-issue-ttt1jk.stackblitz.io/
- Add some fields with Angular Validators in a FormArray (this counts for every field, mat-select, matInput, etc.)

I have HTML like this:
- mat-form-field
-- mat-select
-- mat-error

Or:
- mat-form-field
-- input matInput
-- mat-error

#### What is the use-case or motivation for changing an existing behavior?
Validation needs to be shown on submit so the user knows the field has errors.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
- Angular v5.1.0
- Material v5.0.1
- TypeScript v2.4.2
- Every browser

#### Is there anything else we should know?

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 复现开始,比较添加到 FormArray 的 matInput 和 mat-select 控件的 mat-error 行为。验证提交后以及被触发后未触发的控件。完成标准是:提交时每个无效字段都会显示验证错误,而无需先触发该字段。

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

评估

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

把新 issue 发到你的邮箱

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