gpt4 book ai didi

javascript - 为什么 Angular-debounce 在 v1.3.0 中被破坏了?

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

检查 fiddle :

http://jsfiddle.net/9sqtvcou/1/

在输入中键入一些内容,然后等待 500 毫秒。如果您将“外部资源”更改为版本 1.2.27(从我发布此文章之日起最新的 v1.2),它可以工作,否则就不会。

这是潜在的相关代码:

var debounceDuration = $parse($attrs.debounce)($scope);
var immediate = !!$parse($attrs.immediate)($scope);
var debouncedValue, pass;
var prevRender = ngModelController.$render.bind(ngModelController);
var commitSoon = debounce(function (viewValue) {
pass = true;
ngModelController.$setViewValue(viewValue);
pass = false;
}, parseInt(debounceDuration, 10), immediate);
ngModelController.$render = function () {
prevRender();
commitSoon.cancel();
//we must be first parser for this to work properly,
//so we have priority 999 so that we unshift into parsers last
debouncedValue = this.$viewValue;
};
ngModelController.$parsers.unshift(function (value) {
if (pass) {
debouncedValue = value;
return value;
} else {
commitSoon(ngModelController.$viewValue);
return debouncedValue;
}
});

我不熟悉 Angular,所以我想知道:在 v1.3 中发生了什么破坏了 Angular-Debounce?

编辑:包含技术细节的答案优先于抽象的答案。

最佳答案

我认为这与 breaking change in 1.3.0 有关。尝试将您的 View 更改为:

,而不是自定义指令
<input type="text" ng-model="chapter.title" ng-model-options="{ debounce: 500 }">

http://jsfiddle.net/mblase75/w89ow20f/

关于javascript - 为什么 Angular-debounce 在 v1.3.0 中被破坏了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27276782/

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