Ember,将动作从模板传递到组件时没有动作处理程序
Ember, No action handler when passing action from template to component
我正在尝试将动作从路由传递到模板,然后传递到组件。
app/routes/application.js
actions: {
showModal(context) {
console.log("This needs to be triggered" + context)
},
}
app/templates/application.hbs
{{some-component
showModal=showModal
}}
app/components/some-component/template.hbs
<button {{action "showModal" "The context for the action"}}>Press Me</button>
当运行这个。我收到一条错误消息
"had no action handler for: showModal"
虽然,当我在 templates/application.hbs 中包含操作而不将其传递给组件时,一切正常。只是在将动作传递给组件时。
app/templates/application.hbs
<button {{action "showModal" "The context for the action"}}>Press Me</button>
这行得通。我想在一个组件中调用这个动作。如何将此操作传递给组件?
我正在尝试将动作从路由传递到模板,然后传递到组件。
app/routes/application.js
actions: {
showModal(context) {
console.log("This needs to be triggered" + context)
},
}
app/templates/application.hbs
{{some-component
showModal=showModal
}}
app/components/some-component/template.hbs
<button {{action "showModal" "The context for the action"}}>Press Me</button>
当运行这个。我收到一条错误消息
"had no action handler for: showModal"
虽然,当我在 templates/application.hbs 中包含操作而不将其传递给组件时,一切正常。只是在将动作传递给组件时。
app/templates/application.hbs
<button {{action "showModal" "The context for the action"}}>Press Me</button>
这行得通。我想在一个组件中调用这个动作。如何将此操作传递给组件?