I have a directive that translates the original content, parses it, and uses the information in the original content to help create new content. Its essence is as follows:
.directive('list', function() { return { restrict: 'E', transclude: true, templateUrl: '...', scope: true, controller: function($scope, $element, $attrs, $transclude) { var items; $transclude(function(clone) { clone = Array.prototype.slice.call(clone); items = clone .filter(function(node) { return node.nodeType === 1; }) .map(function(node) { return { value: node.getAttribute('value') text: node.innerHTML }; }); });
Then I use it as follows:
<list> <item value="foo">bar</item> <item value="baz">qux</item> </list>
All of this works great. The problem occurs when I try to use ng-repeat inside the contents of a directive, for example:
<list> <item ng-repeat="item in items" value="{{ item.value }}">{{ item.text }}</item> </list>
When I try to do this, there are no elements. Does anyone know why this will not work, or if there is a better way to accomplish the same thing?
source share