【发布时间】:2015-10-19 06:07:15
【问题描述】:
我的网站目前使用 AngularJS v1.2.8 的 debounce 指令。去抖动在 FF 和 Chrome 中很好,但延迟不会在 IE9 中发生。我对支持 IE9 有严格的要求,我无法升级到更新版本的 Angular。此代码的哪一部分不兼容 IE9?或者,如果有一个已知可在 IE9 中工作的 debounce 指令,将不胜感激。
当前去抖指令:
angular.module('stuff.debounce', []).directive('ngDebounce', function($timeout) {
return {
restrive: 'A',
require: 'ngModel',
priority: 99,
link: function(scope, elm, attr, ngModelCtrl) {
if(attr.type === 'radio' || attr.type === 'checkbox') return;
elm.unbind('input');
var debounce;
elm.bind('input', function() {
$timeout.cancel(debounce);
debounce = $timeout( function () {
scope.$apply(function() {
ngModelCtrl.$setViewValue(elm.val());
});
}, attr.ngDebounce || 1000);
});
elm.bind('blur', function() {
scope.$apply(function() {
ngModelCtrl.$setViewValue(elm.val());
});
});
}
};
});
【问题讨论】:
-
嗯,就在github这个脚本后面,据说不兼容IE9。你最好再找一个!
-
@Apédémak 1.2.8 支持 IE8 及更高版本。 code.angularjs.org/1.2.8/docs/guide/ie
-
@KevinB 我不是在谈论 Angular.... 我说的是在 github 上找到的这个脚本。
-
你可能想澄清你的问题,它一字不差地说:“我正在使用 angular js 1.2.8
标签: angularjs internet-explorer-9 debouncing