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

时间:2016-06-03 06:28:44

标签: angularjs typescript routing

我正在使用typescript以有角度的方式进行路由,但面临路由问题。流似乎是:

enter image description here

我真正想要做的是通过Child进行路由,这是Child2的一部分,Id为Child1的孩子

但它没有显示页面。

插入,更新的Child1的所有路径都位于Child1和Child2本身的路由中,我想从Child2的Child中编辑Child1的一部分的子页面。

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

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

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

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

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