图片加载时, 显示其他图片
.directive('ImgageIsLoading', function ($rootScope) {
return {
restrict: 'A',
link: function (scope, element, attr) {
var timer = setInterval(function() {
if (element[0].complete) {
clearInterval(timer)
$rootScope.$emit('onImagesComplete');
}
}, 50);
scope.$watch(function () {
return attr['ngSrc'];
}, function (value) {
if (!value) {
element.attr('src', attr.hilifeImgageLoadingErrorSrc);
}
});
element.bind('error', function () {
element.attr('src', attr.hilifeImgageLoadingErrorSrc);
})
}
}