4

I've got a web app where the user's can enter 'rich text' content (tinymce) and have possibly entered hyperlinks. In my angular app, I'm rendering this in a div with ng-bind-html-unsafe to preserve all formatting. I would like to attach an 'ng-click' to any an all a hrefs in that content. I created a filter that parses the content and adds the 'ng-click' text to the resulting html. I interrogated the DOM and see the ng-click="alert('test')" but there's something I'm missing where the output from the filter isn't being "wired up" (compiled).

Mark Nadig
  • 4,901
  • 4
  • 37
  • 46
  • I think you need something akin to this: http://stackoverflow.com/a/13405548/295797 – Roy Truelove Dec 01 '12 at 02:33
  • Roy, thanks. I think the real answer is I need to be doing this in a directive, not a filter. That link you gave me gives me a good start. Thanks! – Mark Nadig Dec 01 '12 at 16:42
  • Same problem here, and I suspect you're right about having to use a directive, since using returning the result of $compile from a filter results in errors like `Uncaught Error: 10 $digest() iterations reached. Aborting!` – Nat Jul 29 '13 at 22:31

1 Answers1

0

The real answer is I needed to be doing this in a directive, not a filter. Roy's link https://stackoverflow.com/a/13405548/295797 provided the necessary guidance. [answering own question to clear from 'unanswered' queue]

Community
  • 1
  • 1
Mark Nadig
  • 4,901
  • 4
  • 37
  • 46