如何编译过滤结果前,呈现在angularjs [英] how to compile results of filter before rendered in angularjs

查看:118
本文介绍了如何编译过滤结果前,呈现在angularjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web应用程序,用户的可输入富文本内容(TinyMCE的),并有可能进入超链接。在我的角度的应用程序,我在一个div NG绑定-HTML的不安全preserve所有格式渲染这一点。我想在内容附加一个'NG单击任何一个全部的HREF。我创建了一个过滤器,解析内容,并增加了NG单击文本生成的HTML。我询问的DOM,看到了NG-点击=警报('测试'),但有什么我失踪,其中来自滤波器的输出没有被接线(编译)。

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).

推荐答案

真正的答案是我需要的指令,而不是一个过滤器将这样做。罗伊的链接 http://stackoverflow.com/a/13405548/295797 提供必要的指导。
[从回答自己的问题,以明确的悬而未决的队列]

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

这篇关于如何编译过滤结果前,呈现在angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆