我在带有 Angular 的应用程序中使用 TextAngular 指令。当我插入 youTube 链接(通过工具栏按钮)时,它会在编辑器中显示占位符图像。我希望将所有 html 保存在 $scope var 中,但不包含占位符 html。目前,如果我输出绑定到编辑器(ng-model)的 $scope var,我会得到类似的结果:
"<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>"
两种解决方案。
如果您只是将其输出到屏幕上,请使用ta-bind ng-model="html"
代替ng-bind-html="html"
。这会调用自定义渲染器,将其转换为 iframe 语法。
如果您将其发送回服务器并且不希望将其存储为占位符,请将“taApplyCustomRenderers”注入您的控制器并按如下方式使用它:htmlToServer = taApplyCustomRenderers($scope.htmlValue);
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)