Skip to content

Instantly share code, notes, and snippets.

@andrey-kazakov
andrey-kazakov / content_repeat.js.coffee
Created January 23, 2013 23:26
This AngularJS directive, when added to element, repeats it's content as many times as length of given array (almost like ng-repeat). The main difference is that DOM, once built, don't being changed on each $digest(). If you want to force the changing of repeated content, you should emit an event 'invalidateView' with (optionally) name of the sc…
angular
.module('ContentRepeat', [])
.directive 'contentrepeat', ($compile) ->
priority: 1000
terminal: true
compile: (element, attr, linker) ->
template = $compile(element.html())
element.empty()
(scope, self, attr) ->