简体   繁体   English

儿童的角度路由 - 来自不同父母的孩子

[英]Angular Routing to Child - Child from different parents

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 我真正想要做的是通过Child路由,这是Child2的一部分,ID为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. 插入,更新的Child1的所有路径都在Child1和Child2本身的路由中,并且我想从Child2的Child中编辑作为Child1的一部分的小孩的页面。

Any Help is Appreciated! 任何帮助都会得到赞赏!

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 我使用的是TypeScript $ routeConfig,用于在组件之间进行路由,如下所示

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']); 但它不允许我从另一个组件的子项重定向到itemdetails然后我尝试使用$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. 它驻留在我的应用程序的grandparent中,然后我在祖父组件的默认路由( listofitems )中添加了一些redict逻辑到itemdetails ,它默认重定向到listofitemsanddetails组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM