【发布时间】:2018-11-27 16:55:10
【问题描述】:
我有一个带有输出事件发射器的元素,但我不知道如何捕获该事件。我收到此错误:
“类型'() => void'不可分配给类型'EventEmitter'。”
这是输出
@Output() closeMarkers = new EventEmitter<string>();
这就是我将元素添加到组件的方式:
createPopupComponentWithMessage(latitude, longitude, city) {
const popupEl: NgElement & WithProperties<MarkerNewComponent> = document.createElement('new-marker') as any;
//Set MarkerNewComponent input vars
popupEl.city=city;
popupEl.latitude=latitude;
popupEl.longitude=longitude;
popupEl.closeMarkers = this.testOutput ;
popupEl.addEventListener('closed', () => document.body.removeChild(popupEl));
// Add to the DOM
document.body.appendChild(popupEl);
return popupEl;
}
testOutput (){
console.log('test output');
}
【问题讨论】: