gpt4 book ai didi

html - 禁用 ng 会阻止提交表单元素

转载 作者:行者123 更新时间:2023-11-28 03:16:14 25 4
gpt4 key购买 nike

如 HTML 表单中所述,所有禁用的表单文件将无法在表单提交时提交。

在 Angular JS 中,如果我对输入字段使用 ng-disable,那么如果我这样做,该字段是否会真正提交

<form>
<input type="text" ng-disabled="true" name="foo">
<button type="submit">submit</button>
</form>

如果不是为什么?感觉很傻,但对这个问题有点困惑

最佳答案

如果 ng-disabled 的值为真,库会在元素上设置 bool 值 disabled 属性。我相信official documentation在这个问题上很清楚。我提到的部分:

The HTML specification does not require browsers to preserve the values of boolean attributes such as disabled. (Their presence means true and their absence means false.) If we put an Angular interpolation expression into such an attribute then the binding information would be lost when the browser removes the attribute. The ngDisabled directive solves this problem for the disabled attribute. This complementary directive is not removed by the browser and so provides a permanent reliable place to store the binding information.

关于html - 禁用 ng 会阻止提交表单元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27598909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com