So, i am pretty new to Angular 5 and in my application i have a component that looks something like this:
//imports
@Component({
selector: 'dragdropmagic',
templateUrl: './dragdropmagic.component.html',
styleUrls: ['./dragdropmagic.component.css']
})
export class DragDropMagicComponent {
constructor(/*inject services etc*/) {}
ngOnInit() {
//init stuff..
}
document.getElementById("dragdrop").addEventListener("drop", function (e) {
e.preventDefault();
dragDropMagic(e); /*<--- Throws error "Cannot find name 'dragDropMagic'" */
this.dragDropMagic(e); /*<--- Throws error "Not valid Property for HTML Element" */
})
dragDropMagic(e){
console.log("Do something...");
}
}
What i am trying to do is call the dragDropMagic
function inside the EventListener. How can i achieve this? Normally i would call a method with this.dragDropMagic(e)
unfortunately it doesnt seem to work.