从另一个呼叫一个控制器而不重新加载它 [英] Call one controller from another without reloading it
本文介绍了从另一个呼叫一个控制器而不重新加载它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
导出默认值Ember.Controller.extend({
需要:['another'],
....
callAnother:function(){
this.get('controllers.another')。reloadIt();
}
})
另一个控制器:
导出默认Ember.Controller.extend({
init:function(){
调用API
},
reloadIt:function ){
调用API
}
})
当我调用 this.get('controllers.another')。reloadIt()
。它调用 init
和 reloadIt
。
是否可能调用它,而不需要$ init
,因为它已经被加载。
谢谢。
解决方案
请尝试使用宏为此目的更容易。
export default Ember.Controller.extend({
需要:['another'],
callAnother:Ember.computed.alias('controllers.another.reloadIt'),
动作:{
callController:function(){
this.get('callAnother');
},
}
})
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.
解决方案
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');
},
}
})
这篇关于从另一个呼叫一个控制器而不重新加载它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文