Accessing another routes model

I have data stored in one route that I would like to get from another route. How can I do this?

Perphap the correct way to do this is not call another routes model, but rather grab the data from the same place from both routes? Such as ember data. For this case I just passed a json file according to this basic tutorial:

If the one route is a sub route of the other then you can use modelFor In /routeA/routeB you can use this.modelFor('routeA') to get the model from the parent route. If you’re not talking about the model, then I suggest using a service where one route can place the data in the service and the other route can access that data from the service.

this.modelFor('route-name-here') I typically only use with a parent route that I know would have resolved before the child. Otherwise, use something like ember-data or ember-simple-store.

1 Like