Controller 'needs' property deprecation


#1

I noticed that the controller class’ needs property is now deprecated. When did this change occur? Also, it suggests using Ember.inject.controller() in its place. I cannot find this particular gem anywhere in the API or guides yet. Even the guides still refer to needs when talking about dependency injection.

With that said, how do I use Ember.inject.controller().


#2

Documentation is a bit scarse, but it’s pretty easy to understand from the blog post where they mention it. It’s strange they don’t mention the controller injection though.

http://emberjs.com/api/classes/Ember.inject.html#method_service

From needs:

needs: ['application'],
application: Ember.computed.alias('controllers.application')

To inject:

application: Ember.inject.controller()

You can also create aliases by adding the controller name into the method call:

appController: Ember.inject.controller('application')

It’s worth noting that you can only inject controllers inside a controller; and they will also be deprecated once routable components become stable.


#3

http://emberjs.com/api/classes/Ember.inject.html#method_controller it’s there except oddly marked as private… :expressionless: