vendredi 12 juin 2015

Reuse ember controller for two routes, but pre populate part of model on one of the routes

Lets say we were modelling repositories in an app. We would want to be able to see all of our repo's at /repos/.

We can create a repo at /repos/create. In our model a repo has a owner (user), going down this route I would want my first form field in my create.hbs template to be selecting a user.

But it may also make sense to create a repo through viewing a user at /users/userId/repos, and then perhaps the route being /users/userId/repos/create. The difference here would be that the first field of my form would have the user pre populated.

I know that I can reuse the same controller by specifying this in my route:

controllerName: 'repos/create'

(what would the ember generate statement/ the place to put this route in my folder structure be, for this complex route?)

But how would I pass in the user to the repos/create controller?




Aucun commentaire:

Enregistrer un commentaire