Skip to content

Instantly share code, notes, and snippets.

@rosslavery
Created June 6, 2014 19:33
Show Gist options
  • Save rosslavery/097dd81cac42d4d714d9 to your computer and use it in GitHub Desktop.
Save rosslavery/097dd81cac42d4d714d9 to your computer and use it in GitHub Desktop.
Iconic AngularJS Injection
'use strict';
app.directive('iconic', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
scope.$watch(function() {
// Watch for the number of iconic DOM elements
return element.find('img.iconic').length;
}, function(newLength, oldLength) {
// If a new element was added
if (newLength > oldLength) {
IconicJS().inject('img.iconic');
}
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment