After clicking, I need to access the parent element. Here is the HTML code I have:
<button mat-icon-button (click)="download($event)">
The generated HTML code is as follows:
<button _ngcontent-wsc-c153="" mat-icon-button="" class="" aria-label="">
<mat-icon _ngcontent-wsc-c153="" role="img" alt="download" class="" aria-hidden="true" data-mat-icon-type="font" aria-describedby="cdk-describedby-message-2" cdk-describedby-host="0">download_for_offline</mat-icon><!---->
</button>
In my TypeScript file, I have the following function:
download(event) {
console.log(event);
How can I access the parent element from the event? Currently, event.target
references the mat-icon
, but I need the parent button element. Any suggestions?