如何剥离占位IMG在范围VAR textAngular编辑器? [英] how to strip placeholder img in textAngular editor in scope var?

查看:128
本文介绍了如何剥离占位IMG在范围VAR textAngular编辑器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是与角的应用程序TextAngular指令。当我插入一个YouTube链接(通过工具栏按钮),它显示在编辑器中的占位符图像。我想保存所有的HTML在$范围变种,但没有占位符的HTML。目前,我得到这样的事情,如果我输出这势必会在编辑器中的$范围VAR(NG-模型):

 < P>< IMG类=TA-插入视频TA-插入视频=http://www.youtube.com/embed/cUeMF18zA4Y SRC =的allowFullScreen =真的宽度=300FRAMEBORDER =0高度=250/>&下; / p>中

我真正想要的是这样的:

 < P>< IFRAME SRC =http://www.youtube.com/embed/cUeMF18zA4Y的allowFullScreen =真WIDTH =300FRAMEBORDER = 0高度=250>&下; / iframe中与GT;&下; / p>中


解决方案

两种解决方案。


  1. 如果你只是输出在屏幕上,使用 TA-NG绑定模型=HTML而不是纳克-bind-HTML =HTML。这要求它转换成IFRAME语法自定义渲染。


  2. 如果你发送回服务器,不希望它保存为占位符注入taApplyCustomRenderers'到你的控制器,并使用它作为这样的: htmlToServer = taApplyCustomRenderers($ scope.htmlValue);


I'm using TextAngular directive in an app with Angular. When I insert a youTube link (through the toolbar button) it shows a placeholder image in the editor. I wish to save all the html in a $scope var but without the placeholder html. Currently I get something like this if I output the $scope var which is bound to the editor (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>"

What I really want is this:

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

解决方案

Two solutions.

  1. If you're just outputting it on the screen, use ta-bind ng-model="html" instead of ng-bind-html="html". That calls the custom renderers that convert it to the iframe syntax.

  2. If you're sending it back to the server and don't want it stored as the placeholder Inject 'taApplyCustomRenderers' into your controller and use it as such: htmlToServer = taApplyCustomRenderers($scope.htmlValue);.

这篇关于如何剥离占位IMG在范围VAR textAngular编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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