Angular 2使用@Output

时间:2017-03-01 12:25:34

标签: javascript angular output

我遇到了@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

发生了什么事?

0 个答案:

没有答案