Passing a template parameter via transitionToRoute


#1

I would like to have a user register and then when this succeeds transfer him to the login page with the username pre-filled in the login form so that he only has to re-enter the password.

Is it possible to transition to another route and passing some value to be used in the template?


#2

You can do this with [needs] on the controllers.


#3

Maybe I’m lazy, but rather than point me to a link without documentation and making me search through a bunch of code, perhaps you could provide me with an example.

It’s not clear to me how using needs:[] solves my problem.

Unless I set some external property in that controller and somehow use it when generating the template.


#4

I just created this example on github for you. I don’t know how to improve the example. Perhaps take a look at my commit on a clean “ember new transitionto”

You can set ‘username’ from all routes like your login.


#5

You can pass the route name, a model, and options in the transitionToRoute method. Here is the API:

http://emberjs.com/api/classes/Ember.Controller.html#method_transitionToRoute