jcubic jcubic - 2 months ago 74
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


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