-1
我试图使用@Output
指令来通知父组件当按钮被单击子组件。以下是我的代码:Angular - @Output不工作
父视图
<app-perito-select *ngIf="peritoSelect" (cancel)="cancelPeritoAction()"></app-perito-select>
父控制器
...
cancelPeritoAction(){
console.log('cancel inside parent');
this.selectedAction = undefined;
}
子控制器
...
@Output() cancelAction: EventEmitter<any> = new EventEmitter<any>();
...
cancel(){
console.log('cancel inside child');
this.cancelAction.emit();
}
我跟着this教程,它看起来很简单,但我没有达到父功能。我错过了什么?谢谢。