Skip to content

Instantly share code, notes, and snippets.

View andyshora's full-sized avatar

Andy Shora andyshora

View GitHub Profile
@andyshora
andyshora / backgroundImage.js
Created July 20, 2013 15:01
AngularJS directive to add a custom background image to an element when the app has initialized. For example: <div background-image="{{imagePath}}"></div>
'use strict';
app.directive('backgroundImage', function(){
return function(scope, element, attrs){
restrict: 'A',
attrs.$observe('backgroundImage', function(value) {
element.css({
'background-image': 'url(' + value +')'
});
});