jcubic jcubic - 1 year ago 255
Javascript Question

Angular way to set onerror on iframe

Is there angular way to setup onerror attribute on iframe so I can use angular expressions. I've tried to use this:

<iframe onerror="{{vm.error()}}" ng-src="{{vm.url}}"/>

but got error:

Interpolations for HTML DOM event attributes are disallowed

Answer Source

With default events you cant. But you can create a directive and assign to the iframe. Then in the logic of the directive , register to the onerror event and write your logic

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download