puppeteer701
puppeteer701

Reputation: 1285

$location.search is not updated imediatly

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.

Upvotes: 0

Views: 846

Answers (2)

Tabrez Basha
Tabrez Basha

Reputation: 192

Digest cycle takes time to update the DOM. I had similar issue where I had to reload the page after updating the url.

I used $timeout with code that is required to run after completing the digest cycle.

$location.search('filter', null);

$timeout(function() {
   //the code which needs to run after dom rendering
   $window.location.reload();
}.bind(this))

Upvotes: 1

Ilan Frumer
Ilan Frumer

Reputation: 32357

it waits for a digest..

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

Upvotes: 2

Related Questions