如何在 angular 2 中使用动态插入图像源的 onload 事件

how to use onload event in angular 2 with dynamically inserted image source

我想在下载图像时设置某些标志。我尝试在图像标签和调用函数上使用 onload 事件。我在下面实施的内容出现错误:

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");
}

需要一些文章参考或帮助调试。

谢谢!

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