如何在角度访问从子组件到父组件的函数
尝试从儿童组件(Chips-autocomplete-示例)访问删除函数。但无法在app.component中访问它。当我单击关闭(x)图标时,我想获得它的值。例如,如果我单击Apple Close Icon,我想将Apple文本列入警报。与其他人一样(柠檬,酸橙,橙色,草莓),我正在app.component ts文件中这样做。但不起作用。如何解决这个问题?
app.component.ts:
removeClick(removeval) {
alert(removeval);
}
app.component.html:
<chips-autocomplete-example
(removed)="removeClick(fruit)"
></chips-autocomplete-example>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定我是否正确理解您的问题,但是从孩子那里做父母(以最简单的方式)您可以使用
@Output()removed = new EventEmitter&lt; string&gt;();
和在删除函数中添加this.remeved.emit.emit(frual)(frual)(frual)
in Child,然后在父母中Not sure if I'm understand your problem correctly, but from child do parent (in the easiest way) you can use
@Output() removed = new EventEmitter<string>();
and in remove function addthis.removed.emit(fruit)
in child and then in parent