Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 为什么$location.search在lodash';中使用时会落后一次迭代。去盎司()_Angularjs_Lodash - Fatal编程技术网

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);