我有以下 Angular 标记:
(我在这里缩短了代码片段,完整的代码可以在笔中看到)。
我的问题是模型在每次按键时更新,而不是仅在输入框模糊时更新。我不确定我错过了什么?
我实际上希望指令也能在模糊时触发,它们正在观察模型。我尝试了 default
和 blur
的几种组合。
<div ng-app='test' ng-controller='PController'>
<table>
<tbody>
<tr class="top" ng-repeat-start="person in people">
<td colspan='3'>{{ person.Name }}</td>
</tr>
<tr ng-repeat-end ng-repeat="item in person.Items">
<td>{{ item.AName }}</td>
<td><input
ng-model="item.A" updateana
ng-model-options="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 1000} }" />
{{ item.A }}</td>
</tr>
</tbody>
</table>
</div>
谢谢。
最佳答案
ngModelOptions
自版本 1.3.0-beta.6 起可用。你的笨蛋使用 1.2.20。如果您在项目中使用的是该版本,则尚无可用的 ngModelOptions
。
这里有一个类似的问题:https://github.com/angular/angular.js/issues/7117
请阅读@ggondim 的底部评论(至少截至今天,2014 年 7 月 28 日为“底部”):
A common confusion when reading docs is the selected version in the dropdown before the breadcrumb. I think it should be selected with the latest stable version and not latest beta.
您可能也做了同样的事情:假设文档默认显示最新的稳定版本,而它们显示的是最新的测试版。
关于javascript - 更新模糊在 angularjs 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24990590/