问题
I need to call one controller from another.
export default Ember.Controller.extend({
needs : ['another'],
....
callAnother: function() {
this.get('controllers.another').reloadIt();
}
})
Another controller:
export default Ember.Controller.extend({
init: function() {
calling API
},
reloadIt: function() {
calling API
}
})
When I call this.get('controllers.another').reloadIt(). It calls init and reloadIt.
Is it possible to call it without init because it's already loaded.
Thanks.
回答1:
Please try using macros for this purpose is a lot easier.
export default Ember.Controller.extend({
needs : ['another'],
callAnother: Ember.computed.alias('controllers.another.reloadIt'),
actions:{
callController: function(){
this.get('callAnother');
},
}
})
来源:https://stackoverflow.com/questions/38085510/call-one-controller-from-another-without-reloading-it