angularjs directive that wraps & modifies arbitrary content which includes ng-repeat

199 views Asked by At

I am trying to build a directive that:

  • wraps arbitrary content
  • prepends anchor tags to all 'h4' elements found in that content

Here's a plunker of what I have so far.

Seems to work fine if wrapped content is static but:

entire wrapped content is repeated twice

is my invocation of transcludeFn effectively repeating work that ng-trasclude is doing? Do I need to replace ng-transclude with own impl?

'h4' tags generated by nested ng-repeat are not found by the directive

looks like 'clone' passed to cloneLinkFn in transcludeFn is pre-ng-repeat execution. thought that $compile(clone)(scope) would then produce post-ng-repeat version but that did not work either it seems.

I'd really appreciate a tip or explanation of what I am doing wrong.

thank you, -nikita

0

There are 0 answers