First check whether image exists or not then load the image. This type of implementation gives clean UI view to user. In this example, initially we are loading image then assigning as background image if it exists.


<div id="divID" ng-click="setBackgroundImage($event,'')">
 Sample DIV 1


$scope.setBackgroundImage = function($event, imgLocation) {
    var bgImg = new Image();
    bgImg.onload = function() {
        var myDiv = $; = 'url(' + bgImg.src + ')';
    bgImg.src = imgLocation;


  1. Personally I think overjoyed I discovered the blogs.
    I would recommend my profile is important to me, I invite you to discuss this topic...
    background check mumbai

  2. All things considered, there are a couple of highlights you ought to consider about eCommerce destinations. Above all else, it spares time and work. Product Photography Retouching

  3. It is the fundamental background check approach of American Acme Corporation that all new Staff and indicated new Hourly workers have certain accreditations and criminal and other background data confirmed as a state of business.globe news wire

  4. I am a new user of this site so here i saw multiple articles and posts posted by this site,I curious more interest in some of them hope you will give more information on this topics in your next articles. What day is tommorow



Follow this blog by Email

Popular Posts