[フレーム]
Last Updated: February 25, 2016
·
6.801K
· michalbryxi

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')
});

AltStyle によって変換されたページ (->オリジナル) /