Successfully Call history.pushState() from Angular Without Inifinite Digest?

后端 未结 4 1331
野的像风
野的像风 2021-01-17 16:46

Is there a way to call history.pushState() without angular going into an infinite digest loop?

I\'m trying to migrate my app from backend routing to fro

4条回答
  •  深忆病人
    2021-01-17 16:56

    This is what we do in an Angular 1.2.16 app based on this github comment: https://github.com/angular/angular.js/issues/3924#issuecomment-48592773

    $location.url(myNewUrl);
    $location.replace();
    $window.history.pushState(null, 'any', $location.absUrl());
    

    This code is part of a controller. I'm using it to add a query param to the url without wanting to reload the page. It works in our case.

提交回复
热议问题