【发布时间】:2016-09-18 03:36:03
【问题描述】:
我正在尝试了解关闭操作,并且只是在测试一些代码,但我似乎无法让它工作。在我的index.hbs 模板中,我渲染了一个像这样的组件:
{{test-component test=(action 'foo')}}
在我的index.js 控制器中,我定义了动作foo:
foo: function () {
console.log('foo executed');
},
在我的test-component.hbs 组件中,我有一个按钮可以触发如下操作:
<button {{action (action 'test')}}>Test Button</button>.
但是页面崩溃,我在控制台中收到以下错误:Uncaught Error: An action named 'test' was not found
我可以通过在test-component.hbs 中插入test 操作来再次呈现页面,但是我的印象是您使用关闭操作,您不需要在组件中放置任何东西?我在这里做错了什么?
【问题讨论】:
标签: javascript ember.js