I’m trying to reference an auto-generated controller (meaning Ember is handling the creation of an ArrayController without my declaring it) from the ‘needs’ property of another controller. It appears that I have to declare it explicitly in order to access it in another controller. Anyone know if that’s the expected behavior?
# this.get('controllers.users') is null unless App.UsersController is explicitly declared
App.NewConversationController = Ember.Controller.extend({
needs: ['users'],
users: function () {
return this.get('controllers.users.model');
}.property('controllers.users.model')
});
Took a stab at it, I’m not sure this is the best way but it will work. I know that as of like 1.0-rc1 they removed controller generation for controllerFor which is probably what needs is doing behind the scenes.
http://fiddle.jshell.net/NQKvy/490/
This is great- Thanks for trying it. So I understand that you’re confirming this is indeed the current behavior - if not declared, the ‘needs’ property does not work.
Great example. Questions:
why
this._super.apply(this, arguments);
?
is this.container.has
equivalent to App.__container__.lookup
?
you use Ember.Object.create in the model method - what advantages over just using a regular object in this case (academic discussion perhaps)
Thanks so much!
This is just telling the base route to execute the underlying setupController like it normally would.
No lookup will create the object if one does not exist, has will just determine if the container has the object.