Maybe only a "stylish" but nonetheless...
I've the following which is working:
// Template
<div *ngFor="let media of period.media">
.
.
.
<button #btn (click)="onDeleteClick(btn)" [attr.media-id]="media.ID">
{{'DELETE' | translate}}
</button>
</div>
//component.ts
this.period.media = [
{id: 123}, {id: 456}, ...
];
.
.
.
onDeleteClick(elem) {
console.log(elem._elementRef.nativeElement.getAttribute('media-id'));
}
It works (the console shows 123, 456,...
) but accessing the nativeElelement using the _elemntRef sounds like a hack (underscore denotes Private property, like _privateVar, isn't it).
So what would be a more elegant way to access the nativeElement or, even better, its 'media-id' attribute?
Thanks a lot for any hint.
EDIT
The answer to this question is in the comments from user184994 and JB Nizet. Since they both addressed the problem correctly I cannot set the "accepted answer" flag since it can be assigned to only once.
Therefore I'm editing my question as acknowledgement of this.