Ember Dependencies between multiple controller in latest version?


#1

In the below version of ember 1.13.0 , We handle easily multiple controller dependencies

export default Ember.Controller.extend({ needs: [‘post’, ‘comments’] });

After 1.13.0 , How to handle multiple controller dependencies ,

export default Ember.Controller.extend({ postController: Em.inject.controller(‘post’) });


#2
export default Ember.Controller.extend({
  post: Ember.inject.controller(),
  comments: Ember.inject.controller()
});

#3

Thank you very much @jasonmit . Can i write easily to manage dependencies better than this ? Is this the only way to manage multiple controller dependencies ? I think before 1.13.0 would have easily managed dependencies .For Ex : needs : [ “a”, “b”, “c”, “d” ]


#4

If you’re trying to save some typing and you really have a /lot/ of controllers you need inject, then I guess you could do something like what I typed below. But I’d be more concerned about this controller being so tightly coupled to so many controllers that this is a problem.

const IndexController = Ember.Controller.extend({
  controllers: ['foo', 'bar', 'baz']
});

const proto = IndexController.proto();

proto.controllers.forEach(function(lookupName) {
  proto[lookupName] = Ember.inject.controller(lookupName);
});

export default IndexController;