Angular Routing for a Child - A Child from Different Parents

I use typescript for routing in angular, but ran into some kind of routing problem. The stream is as follows:

enter image description here

What I really want to do is route through Child, which is part of Child2 from Id to Child of Child1

but does not display the page.

The entire route of Child1 is to be inserted, the update is in Child1 and routes Child2 itself, and I want to go to the edit page of the child element, which is part of Child1 from Child of Child2.

Any help appreciated!

+4
source share
1 answer

After a long search, I found one solution that allows me to redirect the parent directly from the child.

What I used is TypeScript $ routeConfig for routing between component below

this.$routeConfig = [ { path: '/', name: 'listofitemsanddetails', component: 'myitemlist', useAsDefault: true }, { path: '/:id/info', name: 'itemdetails', component: 'listitenmdetail' }]; 

But this will not allow me to redirect to itemdetails from a child of another component, and then I tried to use $router.parent.navigate(['listofitems']); which is in the grandparent my application, and then I added some redict logic to itemdetails in the standard route ( listofitems ) of the grandparent component, which is redirected to the listofitemsanddetails component by listofitemsanddetails .

0
source

Source: https://habr.com/ru/post/979165/


All Articles