Best practice for multiple controllers on a route?


I’m sure that my question is a little wonky as I’m an ember newb. Anyway, here’s the setup, I have a CMS editor with its own controller and model (StaticPage and StaticPageController).

Totally straightforward. However, a piece of static content can be attached to an arbitrary system object. E.g. a Product. What I’d like to do is a have a SearchController that handles searching and search API interaction. A user types in a product code/sku and is given a list of matching products that they could attach the static content to. But I’d rather not make that a monolithic part of the editor.

I’m sure this is a common kind of problem, I’m just curious about how this stuff is done in Ember land. Thanks!

(I tried searching but I my search-foo is weak as hell)


Are you talking about having a search view and backing that search view with a different controller. If so, look into the renderTemplate hook on Ember.Route. You can also use the {{render}} helper to achieve this.


Yeah agreed, renderTemplate sounds like what you want. You can also use named outlets in your template if you want it to render somewhere specific, much like the render helper. You can also set up your search controller with the setupController hook.

Some more detail about it here in the docs


Thanks guys! That’s exactly what I was looking for.

Also, Trabus, holy crap. Nice to see you around :smiley: Drop by 12s sometime and say hi to the kiddies!