I have these functions in my index.html of my Angular 2 project:
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", "teststring");
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
console.log(data);
}
</script>
When I put the functions in my component, it gives the following errors:
Uncaught ReferenceError: drag is not defined at HTMLImageElement.ondragstart
Uncaught ReferenceError: allowDrop is not defined at HTMLDivElement.ondragover
the elements using the functions are in the component html:
<div> ondrop="drop(event)" ondragover="allowDrop(event)">
<img> src="smiley.png" draggable="true" ondragstart="drag(event)">
</div>
<div ondrop="drop(event)" ondragover="allowDrop(event)">
</div>