@kadin
In Ember.js, you can pass objects around routes by using the model hook in the Route file. Here is an example of how you can pass an object between routes:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// routes/route-a.js import Route from '@ember/routing/route'; export default class RouteARoute extends Route { model() { return { user: { name: 'John Doe', age: 30 } }; } } |
1 2 3 4 5 6 7 8 |
// routes/route-b.js import Route from '@ember/routing/route'; export default class RouteBRoute extends Route { model(params) { return this.modelFor('route-a').user; } } |
1 2 3 |
<!-- templates/route-b.hbs --> <h1>{{model.name}}</h1> <p>Age: {{model.age}}</p> |
By following these steps, you can easily pass objects between routes in Ember.js.