-
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
Default child state solution does not work with ui-sref links #2255
Comments
Since you are defining what you want to be the "default" state, you have to transition to that state. Default does not mean redirectTo. Thats a feature thats planned for the future. Using regular 'href' doesn't do the same even though it certainly appears to. It actually transition to the child state directly, as if you have put 'parent.childState' in a ui-sref. |
I think I see the difference between default and redirectTo now. So the FAQ entry about setting up a default child state can only ever work for |
I was re-reading the original thread and as per @nateabele response to @pduey, this difference in behavior should not happen. Am I missing something here? |
@filipesilva did you ever get to the bottom of this or find a workaround? Its not clear if there is there in fact a gap in functionality to set a default child state with parent abstract state (when using ui-sref), or if this should be working. |
No, I didn't get any further on this topic. At the moment I just use the |
I managed to work around by removing the abstract state and have the detail targeting the grandparent state. Before: .state('app.resources.products', {
abstract: true,
url: '/products',
template: '<ui-view/>'
})
.state('app.resources.products.list', {
url: '',
template: '<div>Products list</div>'
})
.state('app.resources.products.detail', {
url: '/:productId',
template: '<div>Product detail</div>'
}) <!-- not working -->
<a ui-sref-active="active" ui-sref='app.resources.products'></a> After: .state('app.resources.products', {
url: '/products',
template: '<div>Products list</div>'
})
.state('app.resources.products.detail', {
url: '/:productId',
views: {
'@app.resources':{
template: '<div>Product detail</div>'
}
}
}) <a ui-sref-active="active" ui-sref='app.resources.products'></a> |
(follow up from #497)
As per the FAQs, to setup a default child state you merely have to set
url: ""
on the child.That works well for
href
links, but nor forui-sref
ones, which has the side effect of also makingui-sref-active
not work.Plunkr: http://plnkr.co/edit/MhJael2qqrGtXe4VHsQO?p=preview
The text was updated successfully, but these errors were encountered: