how to create nested routes

815 views Asked by At

I'm not finding it very obvious how to make a route with this structure: http://localhost:9000/#/vendors/557794d4dda4a5b6162aab53/services/413jdjo53j2ojo532

In the latest blog, I am seeing references to child/parent routes and looking up parent params from the child, but in the docs, I only see references to child routers and having a whole new router seems a bit like an overkill for this use case.

What is the best way to create such a route and be able to look up data from the parent route? How do we achieve a route hierarchy (like in Ember for example)?

1

There are 1 answers

2
Matt McCabe On

I've found that the easiest way to share data between child and parent route is use a shared state, just create a class

export class State {
    status = null
}

And then inject it into both the parent and child view models, by default it will be a singleton so you can use it to pass data around.