Angular Bg Image

by Andrew Pougher

HTML

<section ng-app="app">
    <div ng-controller="MyCtrl">

<div class="kitten" ng-style="{ 'background-image': 'url(' + bg + ')' }">
  </div>
    </div></section>

CSS

.kitten {
height: 200px;
width: 200px;
background-repeat:no-repeat;
border: 5px solid #fff;
box-shadow: 2px 2px 1px #eee;

}

JavaScript

angular.module('app', [])

/*
angular.module('app').controller('MyCtrl', function ($scope, $interval) {
var c=1;
 $interval(function() {
  $scope.bg = 'http://lorempixel.com/200/200/animals';
         c++;
    }, 1000);
})
*/
  




.controller('MyCtrl',function($scope,$interval){
var c=0;

      $scope.bg = 'http://lorempixel.com/200/200/animals';
$interval(function(){
  $scope.bg = 'http://lorempixel.com/200/200/animals?r='+c;
c++;
},2000);

});