0

I want to set certain flags when image is downloaded. I tried using onload event on image tag and call function. With what I implemented below I am getting error:

Uncaught ReferenceError: imageLoaded is not defined at HTMLImageElement.onload

component.html:

 <img onload='imageLoaded()' class='doc-img' [src]='imageUrl'>

component.ts:

ngOnInit()
{
  this.getDocumentImage()
}

getDocumentImage()
{
     this.imageUrl= 
this.domSanitizerService.bypassSecurityTrustResourceUrl(`${API.document}/{documentId}`);
}

imageLoaded(){
    alert("image loaded");
}

Need some article reference or help in debugging this.

Thanks!

1 Answer 1

3
<img (load)='imageLoaded()' class='doc-img' [src]='imageUrl'>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.