Ember.js controllerFor() deprecated
Since Ember-1.0.0-rc1 controller method controllerFor()
has been deprecated:
Deprecate Controller#controllerFor in favour of Controller#needs
You can still use function with the same name on Router level:
App.PostRoute = Ember.Route.extend({
setupController: function(controller, model) {
this.controllerFor('topPost').set('model', model);
}
});
But in controllers, you should use needs
, which will tell ember to get desired controller into current scope. Then we can access it via controllers
array:
App.CommentsController = Ember.ArrayController.extend({
needs: "post",
post_a: Ember.computed.alias("controllers.post"),
post_b: function() {
return this.get('controllers.post');
}.property('controllers.post')
});
Written by Michal Bryxí
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ember.js
Authors
ryrych
11.65K
michalbryxi
6.678K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#