In emberjs pre2 we could access controller or any method in controller from another controller in following way:
App.get('router').get('navController').method1();
Can anybody suggest what could be the similar code for emberjs rc1?
Thanks
Since controllerFor
is deprecated, I think the a more correct way would be with needs:
this.get('controllers.nav').method1()
It requires declaring your needs in your controller:
App.YourController = Ember.ObjectController.extend({
needs: ['nav'],
....
Inside a Controller
or a Route
you can try
this.controllerFor("nav").method1()
This was correct answer when the question was asked but since controllerFor
is deprecated, please check the answer by joscas
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