我将自定义角度网格视图作为子组件创建,并且需要在所有父组件中使用它
网格上的每个记录都包含许多操作(编辑-删除)
在子组件消防业务功能中单击编辑按钮时需要 父母
因为我的自定义控件在所有应用程序中都是全局的
答案 0 :(得分:2)
使用@Output
装饰器定义输出属性
模板
<button (click)="buttonClick()">My button</button>
组件
@Output() doBusiness: EventEmitter<any> = new EventEmitter();
buttonClick() {
this.doBusiness.emit(...some data...);
}
父模板
<child-component (doBusiness)="doMyWork($event)"></child-component>
https://angular.io/guide/component-interaction#parent-listens-for-child-event