Skip to content

Going to a state that has emptystring as its url doesn't change your address bar #705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nickretallack opened this issue Dec 20, 2013 · 4 comments

Comments

@nickretallack
Copy link

  1. Make a state whose url is emptystring ("")
  2. Make a link with ui-sref for that state
  3. Go to another state first so there's stuff in your address bar
  4. Click on the link

The state will change, you'll see the new template, but the address bar won't change! This screws up your history, since hitting back will take you back two steps.

@laurelnaiad
Copy link

Visiting states that don't have URLs does indeed not count as a browser-history-worthy event, but it seems to me that that is exactly how it's supposed to work. Did you expect something else?

@nickretallack
Copy link
Author

The state does have a url though. It's emptystring. When the page first loads, this is the route that ui-router matches and displays. I suppose you're saying emptystring is falsy and therefore a non-value, but that makes this behavior nonsensical. If it considers emptystring a matchable url during startup, it should consider it a url during later state changes too, for consistency.

I've worked around this by setting up an automatic redirect to "/" and changing my url to "/".

I'm sure this will by this similar issue. I just thought I'd bring up the fact that emptystring as a url is currently sort of broken, or at least inconsistent in its handling.

@laurelnaiad
Copy link

Oh, I see...sorry for not understanding at first.

What you're calling a workaround is what I always do and I've come not to think of it as a workaround . I use the "empty string state" as an abstract base state, and then I use it it to do some very basic templating and I use its resolve property to resolve promises for things that I want to have available at all times and prior to any real routing taking place -- for instance, in an app I'm working on now I make sure angular-translate's promise is resolved so I know the specified language files are loaded before the user sees anything.

EDIT -- I realize I don't need to assign my abstract base state any URL at all, but I just do it anyway because I'm a creature of habit. :)

@timkindberg
Copy link
Contributor

If you want an "empty" url for a state, use "/". Otherwise this is the correct behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants