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
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
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
In Ember 2, this works by injecting the controller you want access to:
export default Ember.Controller.extend({
nav: Ember.inject.controller(),
});
Or, if you want to specify a name different than the controller name:
export default Ember.Controller.extend({
navController: Ember.inject.controller('nav'),
});
You can then access the injected controller's methods like this:
this.get('navController').method1()