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
Post a Comment