Jenny Mok
Jenny Mok

Reputation: 2804

best way to implement location.path in angularjs

As I know, this is to visit a route and pass param to the url

$location.path('/home').search({key:'value'})

This is to clear every param and url and visit the route, history is keep

$location.search('').path('/home');

How about don't keep the history? Like transactional flow, once the user paid, you don't want to let the user to be able to go back. I know there's history service but I think there's more simpler way to do it. I tried to use valina javascript redirect method but it reloaded the entire page which is inconsisten for my SPA.

Upvotes: 1

Views: 37

Answers (1)

PeteyPii
PeteyPii

Reputation: 379

You can call

$location.search('').path('/home').replace();

and it will not create an extra record in the back-history of the browser.

See documentation here.

Upvotes: 2

Related Questions