本文介绍了角路由到孩子-来自不同父母的孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用打字稿进行角形布线,但是遇到一些布线问题。流程似乎是:

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

我实际上是什么想要做的是通过Child的路由,这是Child2的一部分,具有ID到Child1的Child

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

,但未显示页面。

所有用于插入,更新的Child1路由都驻留在Child1中,而Child2本身的路由则驻留在Child2中,我想从Child2的Child中转到Child1的子页面的编辑页面。

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.

感谢任何帮助!

推荐答案

经过长时间的搜索,我找到了一个解决方案,我直接从孩子重定向到父。

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

我正在使用的是TypeScript $ routeConfig在组件之间进行路由,如下所示

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' }];

但是它不允许我重定向到 itemdetails 来自另一个组件的子项,然后我尝试使用 $ router.parent.navigate(['listofitems']); 驻留在 grandparent 我的应用程序,然后我在默认路由( listofitems itemdetails 添加了一些限制逻辑>)的祖父母组件,默认情况下重定向到 listofitemsanddetails 组件。

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.

这篇关于角路由到孩子-来自不同父母的孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 00:33