Default behaviour for controller needs property


#1

From the guide:

We can also create a binding to give ourselves a shorter way to access the PostController (since it is an ObjectController, we don’t need or want the Post instance directly).

App.CommentsController = Ember.ArrayController.extend({
    post: null,
    needs: "post",
    postBinding: "controllers.post"
});

Why isn’t this behaviour automatic?

Wouldn’t be easier to know that if a controller needs a related controller then that controller would automatically become available as a property for that object?

If this use case is common enough to be provided as boilerplate in documentation, then maybe it’s common enough to be default behaviour?


#2

It’s not automatic to avoid conflicts. If, for example, you had App.CommentController = Ember.ObjectController.extend(...), you’d be unable to access the post property on the comment.


#3

Do you mean if you did something like

App.CommentController = Ember.ObjectController.extend({
    photo: Ember.Object.create({
         src : 'some.jpg'
    })
});

In this scenario, the value would be post that is provided not the post controller? Is this the situation that you’re referring to?