I have the following states in my ui-router state provider:
$urlRouterProvider.when('/parent', '/parent/child');
$stateProvider.state('parent', {
url: "/parent",
abstract: true
});
$stateProvider.state('parent.child', {
url: "/child"
});
Which follows the best practice for having a default child state as explained here in the ui-router docs.
However, when I now include a link in my document somewhere referencing parent with ui-sref
such as <a ui-sref="parent">Link</a>
I always get an error saying I cannot transition to an abstract state. When I enter the URL manually into the address bar and hit enter everything works fine.
Related Plunker: http://plnkr.co/edit/d3Z0tOwC3VCTPqGiB0df?p=preview
How can I combine ui-sref
with default child states?
template
property with the value<ui-view/>
, as the child template/Url plugs in to it. Now if you made a href with<a ui-sref="parent.child">
as @Chris-Preston suggested, your url bar would load /#/parent/child. This helped me out, link. At least if I understood that correctly. Someone let me know if I'm wrong :S