Search code examples
javascriptangulareventsdom-eventsevent-binding

How I do an "onload" event in Angular 5?


I am trying to call a function onload element, like a onload="function()" in Javascript.

So this is the code:

<div class="img-circle" [id]="pet.id" (load)="imgLoad( pet.id, pic )"></div>

Function is working fine, I try with (click) and works, but I try with (load), (onload), (loaded) and not working.


Solution

  • In my function i trying to aplication a style in this div, the params was to set a background-image: url(base64);

    So... I change to this, and works

    [ngStyle]="{ 'background-image': 'url(' + pic + ') '}
    

    Event-binding (load,onload,loaded) doesn't exists.