I'm using next directive to splice array if image src error.

```
myApp.directive("noImage", function () {
    return {
        link: function (scope, element, attrs) {
            element.bind("error", function () {
                var idx = scope.posts.indexOf(scope.post);
                scope.$apply(function () {
                    scope.posts.splice(idx, 1);
                });
            });
        }
    };
});

```

And trying to push spliced items back with function from controller something like.

```
$scope.restorePosts = (function() {
      return function() {
          $scope.spliced_posts.forEach(function(x) {
          return $scope.posts.push(x);
        });
        return $scope.spliced_posts = [];
      };
    });

```

The question is what i should add to directive?
`scope.spliced_posts.push(scope.post)`?

[JSFIDDLE](http://jsfiddle.net/36bvahvc/)