Angular Routing to Child - Child from different parents

故事扮演 提交于 2019-12-23 12:35:30

问题


I am using typescript for routing in angular but facing some issue with routing. Flow seems to be:

What I actually want to do is route through Child which is the part of Child2 with Id to Child of Child1

but it's not displaying the page.

All the route of Child1 for insert, update resides in Child1 and routes for Child2 itself and i want to go to edit page of child which is part of Child1 from Child of Child2.

Any Help is Appreciated!


回答1:


After a long search, i have found one solution which let me redirect to parent from child directly.

What i was using is TypeScript $routeConfig to route between component as below

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

But it won't allow me to redirect to itemdetails from child of another component then i tried using $router.parent.navigate(['listofitems']); which resides in grandparent of my application and then i have added some logic of redict to itemdetails in default route (listofitems) of grandparent component which redirects to listofitemsanddetails component as default.



来源:https://stackoverflow.com/questions/37607364/angular-routing-to-child-child-from-different-parents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!