来自 parent 组件的调用操作 Ember 2.x

Call action from parent component in Ember 2.x

我正在尝试从我的路线视图中的 parent 组件调用一个动作。

mychild.hbs

{{#parent as |wrapper|}}
    <button {{action "animate"}}>Login</button>
{{/parent}}

parent.hbs

<div>{{yield}}</div>

mychild 路线(无操作)

export default Ember.Route.extend(
});

我的孩子控制器

export default Ember.Controller.extend({
});

parent分量

export default Ember.Component.extend({

    actions: {
        animate() {
            console.log('ok');
        }
    },
});

如何从我的组件调用 animate()?我做错了什么?

将以下代码更改为此。似乎有效。

<div>
    {{yield this}}
</div>

{{#my-component as |mc|}}
    <button {{action "doIt" target=mc}}>callDoIt</button> 
{{/my-component}}