首页 文章

数字输入字段不关注验证更改

提问于
浏览
1

当验证状态从无效变为有效时,当前输入字段将失去对firefox(Minimum working example in jsFiddle)的关注:

<div ng-repeat="elem in list track by $index">
    <ng-form name='innerform'>
        <input name="id" type="number" ng-model="elem.id" required/>
        <div ng-if="innerform.id.$error.required">Required!</div>
    </ng-form>
</div>

此行为似乎发生在 Firefox onlyonly with an input field of type 'number' 中 . 将其更改为"text"或使用Chrome,它可以正常工作 .

我在这里做错了还是AngularJS或FireFox中的错误?

2 回答

  • 1

    出现此问题主要是因为type =“number” . 将其更改为type =“email”或其他工作正常 .

    Firefox似乎不支持type =“number”,但是,angular会填充Firefox,以便在Firefox中正确运行type =“number”输入字段(在验证等方面) .

    为了使其工作,它使用输入数字polyfill . SEE HERE

    SEE RELATED QUESTION HERE

  • 1

    当将块插入内联元素而不是AngularJS时,这是Firefox中的一个错误 . 即将推出的FF版本的修复已经开始:https://bugzilla.mozilla.org/show_bug.cgi?id=1045270

    同时caitp在https://github.com/angular/angular.js/issues/8365上提出了一个很好的解决方法:

    添加style =“display:block;”或style =“display:inline-block;” (或者只是在CSS文件或样式标记中添加这些内容)用于受影响的元素(在原始问题的情况下,ng-form)---或者,在块元素上使用ng-form属性 .

相关问题