Last active
August 12, 2018 06:28
-
-
Save rjoydip-zz/18f640c70b7adb431040d48a7973acd2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('imageExists', ['$http', 'IMAGE', | |
function($http, IMAGE) { | |
return { | |
restrict: 'EA', | |
link: function(scope, elem, attrs, ctrl) { | |
$http({ | |
method: "GET", | |
url: attrs.src || attrs.ngSrc | |
}).then(function mySuccess(response) { | |
return; | |
}, function myError(response) { | |
if (response.status === 404) { | |
scope.mainImage = IMAGE.BASE_IMAGE; | |
} | |
}); | |
} | |
}; | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment