【发布时间】:2019-08-05 20:21:49
【问题描述】:
我正在尝试将动作从路由传递到模板,然后传递给组件。
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>
运行时。我收到一个错误提示
“没有针对:showModal 的操作处理程序”
虽然,当我在 templates/application.hbs 中包含操作而不将其传递给组件时,一切正常。只是在将动作传递给组件时。
app/templates/application.hbs
<button {{action "showModal" "The context for the action"}}>Press Me</button>
这行得通。我想在一个组件中调用这个动作。如何将此操作传递给组件?
【问题讨论】:
标签: ember.js