【发布时间】:2019-05-14 17:34:04
【问题描述】:
我有一个反应式表单,当用户在输入中按下 ESC 键时,我想在表单隐藏之前显示“你确定”模式。
一旦显示模态,我就会在控制台中收到以下异常:
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has
changed after it was checked. Previous value: 'ng-untouched: true'. Current
value: 'ng-untouched: false'.
Here is a stackblitz 显示问题(焦点输入并按 ESC)
注意:当您聚焦输入,模糊并再次聚焦时,问题不会显示为ng-untouched 不会再次改变。
有什么解决方法吗?实现此类功能的推荐方法是什么?
提前致谢!
【问题讨论】:
-
这是因为ng-untouched的值变化非常频繁
-
在我的情况下 setTimeout 没有解决问题。在打开确认模式之前,我必须将控件设置为已触摸。
control.markAsTouched()
标签: angular angular-reactive-forms ng-bootstrap