Angular: Empty Fiddle

http://angularjs.org/

by dingen2010

HTML

<div ng-app="myApp">
    <div ng-controller="myCtrl">    
          <div ng-repeat="image in images">
              * <img class="pic" fallback-src="http://google.com/favicon.ico" ng-src="{{image}}"/>
          </div>
    </div>
</div>

JavaScript

var myApp = angular.module('myApp',[]);

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;
});

function myCtrl($scope){
    $scope.images = [
        'http://lorempixel.com/200/150',
        'http://sdfsfsd'
    ];
}