在emberjs中调用视图方法 [英] Calling a method of view in emberjs
本文介绍了在emberjs中调用视图方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的视图中有一个方法,我想从控制器中调用此方法。控制器和视图如下:
App.theController = Ember.ArrayController.extend({
methodA:function(){
//如何在视图
中调用methodB}
});
App.theView = Ember.View.extend({
methodB:function(){
//做某事
}
});
问题是方法A如何调用方法B?
解决方案
此方法可能应该在控制器上。
App.TheController = Ember.ArrayController.extend({
methodA:function(){
//做某事
}
});
App.TheView = Ember.View.extend({
methodB:function(){
this.get( controller)。methodA();
}
});
您可以通过容器的查找方法来引用它们,但这不是推荐的做法。 / p>
I have a one method in my view and i want to call this method from controller.The controller and view is like this :
App.theController = Ember.ArrayController.extend({
methodA:function(){
//how to call methodB in view
}
});
App.theView = Ember.View.extend({
methodB:function(){
//do something
}
});
the question is how methodA can call methodB ?
解决方案
This method should probably be on the controller.
App.TheController = Ember.ArrayController.extend({
methodA:function(){
//do something
}
});
App.TheView = Ember.View.extend({
methodB:function(){
this.get("controller").methodA();
}
});
You can reference both of them through the container's lookup method, but this is not a recommended practice.
这篇关于在emberjs中调用视图方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文