How can I get an ApplicationController inside my HomeController?
 HomeController=Ember.Controller.Extend({
   init:function {
        // Here I want to get My application controller. Is there any way to get??
   }
 })
                How can I get an ApplicationController inside my HomeController?
To specify dependencies (or needs) between controllers, use the needs property:
HomeController=Ember.Controller.Extend({
  needs: ['application']
})
Now Ember will make the application controller accessible from inside your HomeController as controllers.application. You can use it like any other HomeController, it is even accessible from your templates:
<!-- inside `home` template -->
{{controllers.application}}
See http://darthdeus.github.com/blog/2013/01/27/controllers-needs-explained/ for more detail on controller-needs.
BTW: It's pretty rare for an ember controller to use a custom init fx. Consider moving any initialization logic to setupController hook on the route instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With