Pattern for instantiating a view from a controller and setting it up


Hey everyone,

I’m new on the ember learning curve and trying to get my head around some of the “ember-y” ways to do things.

Let’s say I have a component – perhaps something like a little number slider. I use it all over the application, and it has properties like minimum value, maximum value, and step. When a controller comes alive, I want to instantiate an instance of the component and keep it around, maybe as a property. I want to set the minimum, the maximum, and the step. And I want to observe the “value” property of the view to take action when it changes. I suppose I could also implement an action that gets fired when the value changes instead of using observation.

Anyway, what I don’t understand is how to do the setup. It seems like controllers are pretty agnostic to their views.

Thanks, -Dexter


I think what your looking for is in the guides here and here.

Components are designed to do exactly what you’re asking for. If you pass in properties from your controller, then the component will bind to those properties. If it changes in either place, the value will be updated in both places. The second link shows how to set which actions the component should fire on your controller and/or route.

Hope that helps!


This does help, thanks a ton.