I have hyperlink with id parameter
<a [routerlink]="[]" class="someclass" id="12">test</a>
In script I add function call to this element by this
this.elementRef.nativeElement.querySelector('.someclass').addEventListener('click', this.someFunc.bind(this));
this is someFunc
someFunc(param){
console.log('someFunc: '+param);
}
When I run app and press that link I get this in console:
someFunc: [object MouseEvent]
How can I send 'id' param of hyperlink to that function ?
Trying solution from Aakash Garg
this.elementRef.nativeElement.querySelector('.someclass').addEventListener('click', (e) => this.someFunc(e.target.id));
For testing printing out straght:
(e) => console.log('test: '+e.target.class) > prints out test: undefined
(e) => console.log('test: '+e.target.id) > prints out test: