ajoslin / angular-mobile-nav

An angular navigation service for mobile applications
http://ajoslin.github.com/angular-mobile-nav
MIT License
786 stars 135 forks source link

Sometimes doesn't clean up after itself when URL changed manually in a browser #23

Closed gkoberger closed 11 years ago

gkoberger commented 11 years ago

I've found that often when the URL is changed manually in the browser, it leaves the previous frame. I believe I was able to fix it by changing nagivate.js:49 to navigate(self.next, self.current);.

(There doesn't seem to be transitions, which may be intentional?)

I was kind of guessing and am not sure if my change would break something else; hence an Issue rather than a Pull Request :)

ajoslin commented 11 years ago

Hey again Greg!

The library isn't really made for use in browsers at the moment, instead it's for an enclosed webview like Phonegap or trigger.io. If someone presses a normal browser back button or changes the url themselves it doesn't really know what to do.

I tried before to make something that just worked off <a> tags and watched history, but had troubles.

Maybe one day I will look at the anchor links and normal navigate again, if there's enough demand... I would probably have to write a lot more URL tracking to handle backs correctly. We'll see.

The default event is mainly for the very first, automatic navigation - eg to '/'.

gkoberger commented 11 years ago

Actually, I ran into this problem while using PhoneGap. When someone opens a link in the app while the app is already open (ie myapp://myapp/#/home), it was showing both the current and previous page. (I don't have logins; I text people a link that will log them in.)

ajoslin commented 11 years ago

Would you be able to make that work using $navigate instead? You're really not supposed to use normal links or change the URL outside of $navigate at the moment.

I guess your fix would work, though - the defaultRouteSuccess function is really just a "I hope I can catch you when you change URL without using $navigate" attempt to fix. But it actually works pretty well. Could you open a pull request?

And did I mention .. I really really really need unit tests!!!

ajoslin commented 11 years ago

bump. any resolution, greg?

gkoberger commented 11 years ago

Personally, I just did it a different way: I use PhoneGap's handleOpenURL() to trigger $navigate now. I'll close it for now (since I'd hate to add code for my own use-case, especially when I don't know how it actually works), but I'd be happy to submit a pull request if anyone else is having similar problems.