Angular 将事件从子组件传递到父组件

Angular 将事件从子组件传递到父组件,angular,components,interaction,eventemitter,Angular,Components,Interaction,Eventemitter,我对Angular很陌生,这是我的问题: 我有一个子组件,处理网格的单元格单击事件,在回调中有一个EventEmitter,声明为@Output()cellClicked:any。 我正在回调函数中实例化EventEmitter,如下面的示例代码所示: onCellClicked($event){ this.cellClicked = new EventEmitter(); this.cellClicked.emit($event)

我对Angular很陌生,这是我的问题:

我有一个子组件,处理网格的单元格单击事件,在回调中有一个EventEmitter,声明为
@Output()cellClicked:any。
我正在回调函数中实例化EventEmitter,如下面的示例代码所示:

        onCellClicked($event){
            this.cellClicked = new EventEmitter();
            this.cellClicked.emit($event);  
        }
在父组件模板中,我已放置此网格

    <data-grid 
        [gridData]="restrictionsAll.restrictions" 
        [columnDefinitionsPath]="restrictionsAll.agGridConfigPath" 
        (getApi)="getGridApi($event)" 
         >
    </data-grid> 

当我调试代码控件时,它正在到达子组件中的断点,但它没有传递到
cellClicked
方法中的父组件。感谢您在这方面的帮助。

因为您没有在任何地方实施该活动

在容器的父组件中

<data-grid 
    (cellClicked)="cellClickedInParent($event)"
    [gridData]="restrictionsAll.restrictions" 
    [columnDefinitionsPath]="restrictionsAll.agGridConfigPath" 
    (getApi)="getGridApi($event)" 
     >
</data-grid> 
<data-grid 
    (cellClicked)="cellClickedInParent($event)"
    [gridData]="restrictionsAll.restrictions" 
    [columnDefinitionsPath]="restrictionsAll.agGridConfigPath" 
    (getApi)="getGridApi($event)" 
     >
</data-grid> 
cellClickedInParent(event){
   console.log(event) //////// this works
}