如何在范围var中的textAngular编辑器中去掉占位符img?

时间:2014-07-06 23:49:25

标签: javascript angularjs

我在使用Angular的应用程序中使用TextAngular指令。当我插入youTube链接(通过工具栏按钮)时,它会在编辑器中显示占位符图像。我希望将所有html保存在$ scope var中但没有占位符html。目前,如果输出绑定到编辑器的ng scope var(ng-model),我会得到类似的东西:

"<p><img class="ta-insert-video" ta-insert-video="http://www.youtube.com/embed/cUeMF18zA4Y" src="" allowfullscreen="true" width="300" frameborder="0" height="250"/></p>"

我真正想要的是:

"<p><iframe src="http://www.youtube.com/embed/cUeMF18zA4Y" allowfullscreen="true" width="300" frameborder="0" height="250"></iframe></p>"

1 个答案:

答案 0 :(得分:7)

两种解决方案。

  1. 如果您只是在屏幕上输出,请使用ta-bind ng-model="html"代替ng-bind-html="html"。这会调用将其转换为iframe语法的自定义渲染器。

  2. 如果您要将其发送回服务器并且不希望将其存储为占位符,请将“taApplyCustomRenderers”注入您的控制器并使用它:htmlToServer = taApplyCustomRenderers($scope.htmlValue);

    < / LI>