Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lazy loading expensive DOM
directive('lazyHtml', function() {
return {
transclude: 'element',
priority: 1200,
terminal: true,
restrict: 'A',
compile: function(element, attr, linker) {
return function ($scope, $element, $attr) {
var visible = false;
var stopWatching = $scope.$watch($attr.lazyHtml, function(value){
if (value && !visible) {
visible = true;
linker($scope, function (clone) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment