I need to be able to call a function in order to run code to dynamically retrieve the source of an image. The following code snippet shows an example of what I want:
Right, got there in the end:
angular.module('MyApp', [])
.controller('Ctrl2', function($scope) {
})
.directive('mySrc', function() {
return {
restrict: 'A',
link: function ( scope, elem, attrs ) {
//replace test with whatever myFunction() does
elem.attr('src', 'test1');
}
};
});