javascript - overwrite $location pushState history AngularJS -


if returning user "results page" want see last filters used. using ngcookies update last used search parameters on page.

controller('results', ['$location','$cookies',function($location,$cookies){     $location.search(angular.fromjson($cookies.search)); }]);  //will yield: /results?param1=dude&param2=bro 

however, if click "back" not brought last page expect.

that's because state pushed onto history unperceived user.

the user landed on /results controller pushed /results?param1=dude&param2=bro onto state history.

how overwrite or delete state /results "back" return me user expect last page came be?

chain replace() onto end of $location.search call:

controller('results', ['$location','$cookies',function($location,$cookies){     $location.search(angular.fromjson($cookies.search)).replace(); }]); 

this causes last history entry replaced, rather new 1 added.

there reloadonsearch option can set false prevent reloading route when search params change (if want button go /results).


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -