当验证状态从无效变为有效时,当前输入字段将失去对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 only 和 only with an input field of type 'number' 中 . 将其更改为"text"或使用Chrome,它可以正常工作 .
我在这里做错了还是AngularJS或FireFox中的错误?
2 回答
出现此问题主要是因为type =“number” . 将其更改为type =“email”或其他工作正常 .
Firefox似乎不支持type =“number”,但是,angular会填充Firefox,以便在Firefox中正确运行type =“number”输入字段(在验证等方面) .
为了使其工作,它使用输入数字polyfill . SEE HERE
SEE RELATED QUESTION HERE
当将块插入内联元素而不是AngularJS时,这是Firefox中的一个错误 . 即将推出的FF版本的修复已经开始:https://bugzilla.mozilla.org/show_bug.cgi?id=1045270
同时caitp在https://github.com/angular/angular.js/issues/8365上提出了一个很好的解决方法: