In beta version from the child component (let's say 'child1'
) you could tell your parent to load (navigate to) a different child component instead of current by something like that:
_router.parent.navigate(['child2']);
('_router' is injected in constructor)
In RC1 there's no 'parent' property anymore so it seems like the you have to use _router.navigate()
and provide the full url starting from the app root. Something like
/root/grandparent/parent/child2
Now, the question is if the child component is only aware about parent's routes but not about grandparent - how do you do this?
Would be nice to use _router.navigate(['../child2'])
but that gives me a weird errors like "invalid number of '../'.
The only way to get parent's url I found so far is that:
_router.routeTree._root.children[0].value.stringifiedUrlSegments
(you can also get there from OnActivate event)
but this looks just wrong to me. It also might differ depending on the number of parents/grandparents - I haven't tried yet.
So, is there a better way to do that or relative path should work and I'm doing something wrong?
Thank you.