pox*_*pox 6 angular angular-reactive-forms
我与同事讨论了表单应如何操作,对于后端驱动的输入字段应如何响应用户输入,我们有不同的想法。
这个讨论是基于Angular 对原始的定义
“pristine”表示自从该值以这种形式显示以来,用户没有更改过该值。
因此,假设用户有一个自动完成输入来查找附近的机场,当用户选择一个选项时,我们将 的值设置FormControl为所选选项。
据我了解,既然用户选择了该选项,那么 FormControl 就被用户更改了。
我同事的理解是,更改是程序化的,并且是FormControl根据某些后端进程进行更新的,因此该值是“可信的”并被标记为原始的。
原始有更具体的定义吗?一种考虑后端流程或编程输入的方法?
我认为答案在于以下属性的文档中:pristineAbstractControl
/**
* A control is `pristine` if the user has not yet changed
* the value in the UI.
*
* @returns True if the user has not yet changed the value in the UI; compare `dirty`.
* Programmatic changes to a control's value do not mark it dirty.
*/
Run Code Online (Sandbox Code Playgroud)
这里需要注意两件事:
| 归档时间: |
|
| 查看次数: |
9960 次 |
| 最近记录: |