angularjs - ng-src requires a non-empty src attribute on img tag -


the documentation ng-src shows using ng-src should work. however, when try use on image, image doesn't show unless have src attribute specified text.

the following not work:

<img ng-src="{{img.url}}" /> 

the following works:

<img src="placeholder_text" ng-src="{{img.url}}" /> 

try

{{img}} 

instead of

{{img.url}} 

http://plnkr.co/edit/z55czxaex92xztkp8nhn?p=preview

when html loading, ngsrc directive should create src attribute url of ng-src attribute. plnkr example:

input html:

<img ng-src="{{img}}" /> 

js:

app.controller('mainctrl', function($scope) {   $scope.name = 'world';   $scope.img = 'http://mawords.com/images/plnkr.co.gif'; }); 

output html

<img ng-src="http://mawords.com/images/plnkr.co.gif" src="http://mawords.com/images/plnkr.co.gif"> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -