For example, current URL is " http://localhost/#/mail ". I do some actions, and I want to go to the next url:
$location.path("mail/inbox/3")
It works good. I'm in another controller with another URL. But when I click by "Back" browser button I hope to be returned to "mail" route, but instead of it I'm gone to "mail/inbox" route. Why? How can I fix it? Because it's incorrect for me. Thanks.
When you fire up this baby:
$location.path("mail/inbox/3")
Do remember that it traversed through when('mail')
and when('mail/inbox')
to reach when('/mail/inbox/:number')
. The route went from mail -> inbox -> #3
. This is why when you hit back it goes to mail/inbox
.
This is a messy situation to fix. ng-router
or ui-router
are good when thing are simple, but as application grows, bugs like your are unavoidable.
In my projects I disable the html5Mode
with $locationProvider.html5Mode(false);
, essentially disabling the back button. And add custom back buttons inside the App for user to navigate back.
This solution helps with:
I hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.