Angularjs 为什么$location.search在lodash';中使用时会落后一次迭代。去盎司()
我有以下片段:Angularjs 为什么$location.search在lodash';中使用时会落后一次迭代。去盎司(),angularjs,lodash,Angularjs,Lodash,我有以下片段: $scope.$watch('filters', _.debounce(function(newValue, oldValue) { $location.search({test : newValue}).replace(); }, 500), true); 发生的情况是,url只在第二次迭代时更新,然后落后于一次迭代。意思是第二次显示第一次,等等 有什么线索可以解释为什么会这样吗?那是因为loDash\uuBounce有第三个options参数,该参数有一个前导的
$scope.$watch('filters', _.debounce(function(newValue, oldValue) {
$location.search({test : newValue}).replace();
}, 500), true);
发生的情况是,url只在第二次迭代时更新,然后落后于一次迭代。意思是第二次显示第一次,等等
有什么线索可以解释为什么会这样吗?那是因为
loDash
\uuBounce
有第三个options
参数,该参数有一个前导的选项,默认情况下该选项为false
尝试:
好的,明白了,谢谢你。当我查看文档时,我不太理解这些参数。检查了源代码,现在获取它。
$scope.$watch('filters', _.debounce(function(newValue, oldValue) {
$location.search({test : newValue}).replace();
}, 500, {leading: true}), true);