我正在尝试在 ember 中构建一个模态框组件。模态框有两个标准按钮,“关闭”和“保存”。我想将控制器动作传递给这个组件,以便在单击保存按钮时,它会调用传递的控制器动作。我称我的组件为:
{{#affi-modal-box title="Test title" modalId="createNewAnalyticsRunModal" controllerBinding=controller}}some message{{/affi-modal-box}}
和我的组件:
AS.AffiModalBoxComponent = Ember.Component.extend({
attributeBindings: ['modelId','test'],
//this is the function that gets called when save button is clicked
onSaveButtonClick : function(){
console.log(this.controllerFor('analysisTemplates'));//fails
console.log(this.get('controller'));//returns modal box component which I don't need
}
});
有什么想法可以将控制器对象传递给组件吗?
谢谢。