Under my Angular App, I'm using some 3rd library widget which is rendering in my component.
My template is:
<div>
<myWidGet></myWidGet>
</div>
Inside myWidGet there some button element that I want handle their events.
The button have those classes : .dx-edit-row .dx-command-edit .dx-link-save
so i i do that :
export class myClass AfterViewInit {
constructor(private elRef: ElementRef){}
ngAfterViewInit() {
this.elRef.nativeElement.querySelector('.dx-edit-row .dx-command-edit .dx-
link-save').on('click', (e) => {
alert('test');
});
}
}
My purpose is to get reference to my button and handle the click event from it.
Suggestions?
myWidGetwithViewChildand try getting button withquerySelector. Although, this way of doing things is not "Angular" way, that button should emit anOutputevent...clickevent handler on thedivand check the classes of theevent.targetto determine if the widget button was clicked (assuming that theclickevent propagation was not stopped).