Is it possible to check if by a given url the image exists and it\'s an image resource ?
for example:
angular.isImage(\'http://asd.com/asd/asd.jpg\')
You can use ng-src
Another way is you check if the it exists using the http module.
var app = angular.module('myapp', []).run(function($http){
$http.get('http://asd.com/asd/asd.jpg',
//success
function(data){
};
});
Update:
HTML
JS
var app = angular.module('app', []);
app.directive('isImage', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('load', function() {
alert('image is loaded');
});
}
};
});
app.controller('Ctrl', function($scope) {
$scope.src ="http://asd.com/asd/asd.jpg";
});