.directive('newImage', ['$timeout', '$ionicPopup', '$compile', 'Utils', function ($timeout, $ionicPopup, $compile, Utils) { return { link: function ($scope, element, attrs) { function LoadNewImage(url) { var Img = new Image(); Img.onload = function () { $timeout(function () { element.attr('src', url); }); } Img.src = url; } attrs.$observe('newImage', function (newValue) { if (newValue) { LoadNewImage(newValue); } }); } } }])