1
votes

I have routes, one parent route and some children. Parent router have Resolve.

{path: ':orderId', component: OrderComponent,
    resolve: {order: OrderResolver},
    children: [...]}

All routes in "ngOnInit" get resolver data from Resolver determined for patent route:

let data = this.route.snapshot.pathFromRoot.reduce((pv, cv) => Object.assign(pv, cv.data), {});
this.order = data['order'];

In first child route I update ORDER and navigate to second child route. But in second i get from resolver not-updater data['order']. How I can run parent resolver from child route after update ORDER and in all sibling routes get actual data['order']?

1

1 Answers

0
votes

data will not be resolved again if you are just navigating from one child to other child of same parent. It will only be resolved if you navigate away from your parent :orderId path.

What you may try is returning a Observable of order data, which you can set in sibling routes. and subscribe in child routes to get updated details. But know that when you navigate away from :orderId path and come back you will get a new Observable as the data will be resolved again.

Having said that , that is not a good pattern and I would recommend to use a service instead for data manipulation at a central place, if you know that you are going to update data among children.

Hope this helps!!