Is it possible to utilize the onerror property of the img tag when src.bind is used?

Is it possible to utilize the onerror property of the img tag when src.bind is used?

For example, let’s say I want to use a default image if the src.bind one is not found/404:

<img src.bind="icon" onerror="this.onerror=null; this.src='/images/default-icon.jpg'"/>

Or, alternatives, remove the invalid image icon:

<img src.bind="icon" onerror="this.onerror=null; this.src=null;"/>

I can’t get it to work. I’m wondering if Aurelia is clearing out my onerror set value. Thoughts?

More can be found at this stackoverflow question on onerror and w3scools. Here is how Angular does it.

I’d say to try using error.delegate or error.trigger

Thanks. I’ll give that a shot.