$location.search is not updated imediatly

2019-08-31 12:24发布

问题:

I have a problem that my url doesn't get updated every time i set it. It is somehow connected with the directive, because in other cases it works.

So my question is, on what is the $location.search('dd', val) depended on, what is it waiting for, because function gets called, but the url is not updated.

回答1:

it waits for a digest..

$scope.$apply(function() {
   $location.search('dd', val)
})