Ember.js w / connectOutlet template context

When i do

var bob = App.MyModel.create().setProperties({ name: "bob marley" }); router.get('applicationController').connectOutlet('my', bob); 

The MyModel instance becomes the content property of the MyController instance. From what I read in the manual, the controller instance becomes the context for the handlebars template displayed by MyView .

Does this mean that I should always prefix the model properties with content. in templates?

 <h1>{{content.name}}</h1> 

is there something i don't see or is this the right way to do this?

+4
source share
1 answer

If App.MyController extends Ember.ObjectController , you should be able to directly use {{name}} . This is because Ember.ObjectController extends Ember.ObjectProxy , making the content link unnecessary.

If you use Ember.Controller , you have to prefix the properties with content. , as you said. For more information, see the @trek controller documentation recently completed.

+2
source

All Articles