How to listen for child event from parent directive in Angular2

前端 未结 1 1426
攒了一身酷
攒了一身酷 2021-01-26 12:29

I have a child component \'my-component\' which is wrapped by a Directive \'MyDirective\' , I need to emit an event to parent directive from the child component, I know how to d

相关标签:
1条回答
  • 2021-01-26 12:44

    One approach is to use a template variable and reference it in an event handler:

    <div myDirective #mydir>
        <my-component (someEvent)="mydir.someMethod()"></my-component>
    </div>
    
    0 讨论(0)
提交回复
热议问题