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

$stateNotFound event not called #1356

Closed
ghost opened this issue Sep 11, 2014 · 7 comments
Closed

$stateNotFound event not called #1356

ghost opened this issue Sep 11, 2014 · 7 comments

Comments

@ghost
Copy link

ghost commented Sep 11, 2014

Hi,

I have a problem when using UI Router 0.2.11 and Angular 1.3-rc.0. My app is lazy loading modules (and their routes). But new implementation of uiSref directive provides custom e.preventDefault(), which is called by Angular's htmlAnchorDirective and cancels state transition - so it does not trigger $stateNotFound where I loaded new module.

The problem is that link pointing to a state that has not been resolved yet has no href attribute.
https:/angular/angular.js/blob/2e641ac49f121a6e2cc70bd3879930b44a8a7710/src/ng/directive/a.js#L35

I believe this commit changed this behavior:
2e6d916

Is it a bug or should i use another approach?

Thanks

@christopherthielen
Copy link
Contributor

It's not yet supported. ui-sref assumes all states are loaded at config time. Sorry that the defaultPrevented is causing you issuesl. I'm open to ideas.

@ghost
Copy link
Author

ghost commented Sep 12, 2014

ui-sref is work

@ghost ghost closed this as completed Sep 12, 2014
@ghost ghost reopened this Sep 12, 2014
@ghost
Copy link
Author

ghost commented Sep 12, 2014

Sorry for the issue close - writing comment on the phone is not ideal :).

ui-sref directive is working fine. When i clicked on link without existing state, $stateNotFound was called and then new module with routes was loaded - in v0.2.9.

Could ui-sref set some non-empty value to href attribute of the link to prevent Angular's anchor directive to prevent the transition? I don't know UI router internals and if this could cause some issues.
Otherwise I will just disable anchor directive and it should work fine again.

@christopherthielen
Copy link
Contributor

I just wrote PR #1363 for a different but related issue. This PR doesn't quite fix your problem, though, because you don't have a state at all, as opposed to having a state with an empty URL.

I ran into this same issue with "future states" and ended up not using ui-sref at all.

Maybe we could add something to ui-sref-opts that forces a link to be navigable. I'm still working on that PR. Let me take a closer look.

@christopherthielen
Copy link
Contributor

@neonncz can you try with the latest ui-router?

https://gist.github.com/christopherthielen/99f1ffb873493c83bb26

@ghost
Copy link
Author

ghost commented Sep 15, 2014

Great, this release works.
Thanks for the fix :)

@christopherthielen
Copy link
Contributor

@neonncz great. Although that's not a 'release' really, I just built the current master branch. This will be in 0.2.12

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

1 participant