我遇到了@Output指令的问题。这是我的代码:
代表-list.component.ts
@Output() selected = new EventEmitter();
showRepresentative(event){
this.selected.emit(event.data);
}
app.component.html
<ar-representatives-list (selected)="onRepresentativeSelected(data)"></ar-representatives-list>
app.component.ts
onRepresentativeSelected(data){
console.log(data);
}
当它发出selected
事件时,它会返回以下错误:
Uncaught TypeError: self.context.onRepresentativeSelected is not a function
发生了什么事?