Básicamente, esta es la solución que terminé usando.
$ apply () solo debe ser utilizado por fuentes externas en las circunstancias adecuadas.
en lugar de usar aplicar, lancé la actualización del alcance al final de la pila de llamadas. Funciona tan bien como "scope. $ Apply (attrs.imageonload) (true);".
window.app.directive("onImageload", ["$timeout", function($timeout) {
function timeOut(value, scope) {
$timeout(function() {
scope.imageLoaded = value;
});
}
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('load', function() {
timeOut(true, scope);
}).bind('error', function() {
timeOut(false, scope);
});
}
};
}]);