I have to following directive that I am trying to set an onload listener for the img tag. Inside that link function I programmatically generate the img src.
angular.module('test', [])
.directive('imgTest', function() {
return {
restrict: 'A',
template: '<img ng-src="{{imgSrc}}"></img>',
link: function(scope, elem) {
elem.on('load', function() {
console.log('image loaded');
});
scope.imgSrc = "someurl?token=" + getAccessToken();
}
};
});
However the onload function is not firing. Please go easy, I am sure I am doing something really stupid :)