I have a line drawn through svg and I need to catch the click event on it. However when I set the onclick to a function, I get an error.
<div id ="middle" class="col-lg-2 col-xs-3">
<svg width="300" height="2000" xmlns="http://www.w3.org/2000/svg">
<line id="line2" [attr.x1]= "from_x0"
[attr.y1]="from_y0" [attr.x2]="to_x"
[attr.y2]="to_y" stroke-width="2" stroke="green"
onclick ="OnClick()"//>
</svg>
</div>
The error I am getting is
Uncaught ReferenceError: OnClick is not defined at SVGLineElement.onclick (:3000/#/app/tables/tablelist/tableedit/1:1)
My OnClick function is below
OnClick (){
console.log('clicked on line')
}
Would appreciate any pointers to resolve this.
Angular event binding is (event)="..."
<line id="line2" [attr.x1]= "from_x0" [attr.y1]="from_y0"
[attr.x2]="to_x" [attr.y2]="to_y" stroke-width="2" stroke="green"
(click)="OnClick()"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With