angularjs - Angular directive for a fallback image -


if image on separate server doesn't exist i'd display default image. there angular directive accomplish this?

no can create one.

http://jsfiddle.net/fdkkf/

html:

<img fallback-src="http://google.com/favicon.ico" ng-src="{{image}}"/> 

js:

myapp.directive('fallbacksrc', function () {   var fallbacksrc = {     link: function postlink(scope, ielement, iattrs) {       ielement.bind('error', function() {         angular.element(this).attr("src", iattrs.fallbacksrc);       });     }    }    return fallbacksrc; }); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -