As I am new to ember i don't know how to pass an Array of Objects from one route to another route in ember? (without using query params).Do i need a SessionStorage?
How to pass Array Of Objects from One route to Another Route in EmberJS (Without using query params)
Asked
Active
Viewed 428 times
1
-
Welcome to Stack Overflow! Please take the tour and read through [How do I ask a good question?])(https://stackoverflow.com/help/how-to-ask) and post a [Minimal, Complete, and Verifiable](https://stackoverflow.com/help/mcve) example of your attempt and say specifically where you're stuck. – brass monkey Aug 28 '18 at 14:58
2 Answers
2
Often when data needs to be shared between routes, it should either be saved in the local data store using Ember Data, or you can use a Service. Be careful not to create too many services holding data or you can end up with a mess.
For example, say you create a service called formOptions. You can inject the service in your routes and get the data like formOptions.myData
.
More on services: https://guides.emberjs.com/release/applications/services/

handlebears
- 2,168
- 8
- 18
1
You can do this with sub / nested routes with modelFor
see: Difference between this.get('model') and modelFor
docs: https://www.emberjs.com/api/ember/3.3/classes/Route/methods/modelFor?anchor=modelFor
is this what you mean?

NullVoxPopuli
- 61,906
- 73
- 206
- 352
-
1Oh..Thank You! But what if, i want to pass an Object from one controller to another controller...(I am not assigning my object to model here!) – Aswath Aug 28 '18 at 15:01
-
why do you want to pass objects around in controllers? (also, why not use the model hook?) – NullVoxPopuli Aug 28 '18 at 15:04
-
there is controllerFor: https://www.emberjs.com/api/ember/3.3/classes/Route/methods/controllerFor?anchor=controllerFor – NullVoxPopuli Aug 28 '18 at 15:04