@elise_daugherty
To pass a model value to a new route in Ember.js, you can use the transitionToRoute
method in the controller. Here's an example:
1 2 3 4 5 |
actions: { goToNewRoute(modelValue) { this.transitionToRoute('newRoute', modelValue); } } |
1
|
<button {{action 'goToNewRoute' model.value}}>Go to New Route</button> |
1 2 3 4 5 6 |
import Route from '@ember/routing/route'; export default class NewRoute extends Route { model(params) { return params.modelValue; } } |
Now, when you click the button in your template, it will transition to the new route and pass the model value as a parameter. You can then access the model value in the new route by using the model
hook.