Reputation: 3784
I am testing the HTML5 drag and drop with the Angular application. Just wondering what is wrong here. I have the below code in the app.component.html file.
<div>
<p draggable="true" ondragstart="drag(event)">Coffee</p>
</div>
And I have this in the Typescript file app.component.ts
export class AppComponent {
function drag(ev) {
console.log(ev);
}
}
It says reference error in the console of the browser. Why is it not outputting anything on the console? Please advise!
Upvotes: 1
Views: 2885
Reputation: 36
In angular2/4/5/6/7/8 replace (onevents) with (events) see the example below
ondrop with (drop)
ondragover with (dragover)
ondragstart with (dragstart)
Upvotes: 2