-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Child default state issues with the ui-sref & URL #948
Comments
I'd wanted this a long time ago, but it kept getting shot down. I agree that we should be able to transition to an abstract state if it has a default child, that's just my opinion though. |
I'll think about it. Might just be a matter of how to work it into the API cleanly. |
Would be great if this could be added. |
This caught me for the past few days... I would definitely endorse a fix. I did it slightly different, using a redirect. So, to follow the initial example: ui-sref to 'parent' does not work HOWEVER ... pretty inconsistent behavior. |
+1 "ability to transition to an abstract state with default child" |
+1, for what it's worth. Not being able to do this makes for some gnarly |
+1 |
+1, just got bit by this |
+1 Currently trying to use active navigation using "ui-sref-active" with child states. If the parent state is abstract and a nav button, we lose the ability to use ui-sref-active. |
+1 |
2 similar comments
+1 |
+1 |
+1 for better consistency in the concept of default child state. |
+1 |
You can use this to work around this problem (especially the ui-sref-active problem): $stateProvider.state('parentState', {
url: '/parent',
views: {
'': {
template: '<p>Parent <ui-view /></p>',
controller: function() {}
},
'@parentState': {
template: '<span>Child</span>',
controller: function(){}
}
}
}); Note: the state /parent/child is no just /parent |
@slessans
and
Still |
@iven if |
@slessans You're right. I was using 0.2.8. |
+1 |
1 similar comment
+1 |
+1, being unable to use ui-sref for abstract parents is really problematic. |
+1 Just got caught into this. |
+1 |
1 similar comment
+1 |
+1 |
3 similar comments
👍 |
+1 |
+1 |
Yes, please make it's possible to use abstract states with |
+1 |
Lots of interest in seeing this done. @nateabele @timkindberg is this a feature that you are still willing to accept a PR for? |
For now, don't declare your state abstract, and use this recipe:
|
@christopherthielen that seems to work pretty well. Why not make that part of ui-router? |
@eddiemonge something pretty similar will likely make it in See #1235 |
+1 |
@christopherthielen +1 fixed my issue |
+1 |
1 similar comment
+1 |
+1 |
+1 (@christopherthielen pretty clever ) |
+1 |
+1 |
2 similar comments
+1 |
+1 |
@christopherthielen Thanks 👍 |
+11 |
In the FAQ https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#wiki-how-to-set-up-a-defaultindex-child-state
For option 1, you can add a default child state by making the parent state abstract and adding a url to the parent state and allowing the default child state an empty url so it can inherit the parent url and match the parent state's url.
The option 2 is redirection.
However when you go about trying to transition to it such as using ui-sref, it can no longer transition to the parent state anymore. (This is because the parent state is an abstract state).
These things don't work:
These however work:
It seems non-intuitive to go about setting up a default childstate and then in the process lose the ability to transition to the parent state. If I could just setup a default childstate, and then transition to the parent state, ui-router should be able to just fallback onto the default child state. I shouldn't need to explicitly set the childstate that I want to go to. What if I want to change what my default child state is? Now all my state declarations need to change!
The option 2 of this child state setup opens up possibility of duplicate content. If you combine option 2 with removing
abstract:true
from the parent state, and have the child state have its own url segment, then it is a possible solution to the above problem. But surely hardcoding redirection should not be required.The text was updated successfully, but these errors were encountered: