ng-holder
ng-holder copied to clipboard
use attr.$observe
Hi,
this fixes case where ngSrc directive is used and 'src' property is not yet interpolated -> holder.js cannot show any image.
attrs.$observe('src', function(value) { Holder.run({images:element[0]}); });
// example ctrl function($scope) { $scope.myHolder = 'holder.js?200x200'; }
// example directive ( without $observe holder.js cannot display image, because 'src' attribute is not ready yet) <img ng-src="{{myHolder}} />
Do you need to use the ngSrc
directive? Don't both of these methods let you lazily set the path?
<img holder="holder.js/200x200/text:?">
<img holder data-src="holder.js/200x200/text:?">
It's been a while since I wrote this directive, but I thought the point of using data-src
was to avoid these issues with src
.
Those probably work ok, but my placeholder image sources are coming from RESTful API and angular view template contains final code, meaning that I don't have data-src over there, instead ng-src.