cracker cracker - 5 months ago 8
AngularJS Question

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:

enter image description here

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!

Answer

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.