Skip to content
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

Using an href of # no longer resets ui-router state #2216

Closed
Deklin opened this issue Aug 31, 2015 · 10 comments
Closed

Using an href of # no longer resets ui-router state #2216

Deklin opened this issue Aug 31, 2015 · 10 comments

Comments

@Deklin
Copy link

Deklin commented Aug 31, 2015

I'm not sure when this broke, but you can see in this plunkr ahref="#" no longer triggers a change

http://plnkr.co/edit/GPpzcBP0Ewc5bH5MZE03?p=preview

You can click the RESET link after making some changes to reset to ahref="#" and nothing happens, previously this did work.

This code would respond to this change;
$urlRouterProvider.when('', '/GOHERE');

This no longer gets triggered when an href="#" is used.

@Deklin
Copy link
Author

Deklin commented Aug 31, 2015

Updated plunkr with logging, you will notice $stateChangeStart never fires when RESET is clicked.

@eddiemonge
Copy link
Contributor

Thats not a reset. What exactly are you trying to do? Also, do you have HTML5Mode turned on?

@Deklin
Copy link
Author

Deklin commented Aug 31, 2015

html5mode is off

This used to be working, but no events are fired anymore, basically href="#" is a no-op now.
Sorry for calling it a 'reset', better term to use?

@eddiemonge
Copy link
Contributor

Why not use ui-sref="yourHomeStateName"?

@Deklin
Copy link
Author

Deklin commented Aug 31, 2015

We don't want to encode the home state in the view templates, we want the router to use the .otherwise, or .when like it previous did. This allows us to have it run through that logic (as it should) to make the determination of where to go.

This was working previously as mentioned, but I didn't see a documented breaking-change so i'm trying to see if this is a ui-router defect.

[EDIT]
It is also worth noting that ui-router 0.2.15 + angular 1.2.28 works fine with this, 0.2.15 + 1.4.4 doesn't.

Here is a log of the stateChangeStart with 1.2.28
Object {name: "$stateChangeStart", targetScope: Scope, defaultPrevented: false, currentScope: Scope} Object {url: "/home", templateUrl: "partial-home.html", name: "home"} Object {} Object {name: "", url: "^", views: null, abstract: true} Object {}

@eddiemonge
Copy link
Contributor

The change occurred in 1.3 and it looks like its angular related. I think they are preventing the default action on locationChangeStart. Again though, what you are trying to do isn't a reset. It worked before by having the whole page reload instead of going to a new state. I still think what you want is ui-sref maybe with a reload:true option.

@eddiemonge
Copy link
Contributor

Closing this as it doesn't seem to be a ui-router bug

@Deklin
Copy link
Author

Deklin commented Aug 31, 2015

Would you have the background to open up a defect against 1.4.4 angular? I'm not sure what the breaking change was.

@Deklin
Copy link
Author

Deklin commented Aug 31, 2015

Unfortunately this also breaks browser back navigation. because if you click back and end up at a # starting point, it will not work properly.

@Deklin
Copy link
Author

Deklin commented Aug 31, 2015

angular/angular.js#12175

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

2 participants