【发布时间】:2018-05-25 09:15:22
【问题描述】:
我在另一个组件(父级)的页面 html 中有一个组件(子级):
<div>
<child-component (focusEmit)="startAnimation()"></child-component>
</div>
在子组件中有一个输入:
<input type="text" (focus)="focusFunction()"/>
focusFunction() 向做某事的父级发出一个事件。
我不想以这种方式解决这个用例。我希望子组件是干净的(因为我还有其他嵌套组件,这个用例被简化了,我不想要一长串输出发射)。
还有另一种方法是父级在其子级组件中包含的输入中捕获事件焦点?
【问题讨论】:
标签: angular parent-child communication angular-components onfocus