Created
October 30, 2015 22:09
-
-
Save zdenekhatak/79b5a144f75de195e8ae 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
(function() { | |
'use strict'; | |
angular | |
.module('app') | |
.directive('preloadImages', preloadImagesDirective); | |
preloadImagesDirective.$inject = []; | |
function preloadImagesDirective() { | |
return { | |
restrict: 'A', | |
link: function($scope, el, attrs) { | |
var evaledImages = $scope.$eval(attrs.images); | |
if (angular.isArray(evaledImages)) { | |
var images = evaledImages; | |
} else { | |
var images = attrs.images.replace(/'/g, "").split(','); | |
} | |
angular.forEach(images, function(value) { | |
var img = new Image(); | |
img.src = value; | |
}); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment