angularjs - How to call a function in "ng-src" -


i need able call function in order run code dynamically retrieve source of image. following code snippet shows example of want:

<!-- "myfunction" exists in current scope --> <img ng-src="myfunction()" /> 

i'm sure has simple can't find in ng-src documentation! else ever hit this?

thanks in advance!

the directive (example based on answers)

others recommended directive. can't post client code wrote short example of in plunker (see here). core directive is:

app.directive("imagesource", function (){   return { link: function (scope, element, attrs){       element.attr("src", scope.imageurlarray[attrs.imagesource]);     }   }; }); 

i know have here example done ng-repeat using variable in ng-src serves example of directive would if 1 necessary.

<img ng-src="{{myfunction()}}" /> 

fiddle


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -