【发布时间】:2013-12-23 05:57:05
【问题描述】:
好的,这应该很简单......
使用角度。 我输出一个文本,已经用 textarea 编辑过:
{{model | newline2br}}
如果我不添加过滤器,所有新行都会被忽略。
所以我做了一些谷歌搜索,并写了一个过滤器,newline2br,
就是这样做的——用<br />替换新行
但现在文本显示为文字 <br />!
这是检查窗口中的输出:
<div ng-show="showText" ng-mouseleave="showText = false" class="textwrapper ng-hide">asdjfhaslkjdfh aoiuyqoiweury iufyaoiusydf oiuaysdfiouy aiuysdfoiuy asdfo iuyasdf iouyasdfoiuy asdoifuy aoiusydf oiauysdfoiuays df oiauysdf iouaysdofiuy asioduyf aoiusydf oiauysdfo iuyasdoiufy aoisudyf oiuaysdifuy asdoiufysf<br />hello this is cool<br />I just found out that I can do shift-enter!<br />now I solved the problem with this... :))))</div>
这是为什么呢? 如何正确编写过滤器以便 div 显示新行?
【问题讨论】:
-
你能在 jsfiddle 上展示你的代码吗?很难确定发生了什么。
-
好吧,我没有设法让 jsfiddle 运行 angular...但是代码在那里:jsfiddle.net/VLCSL
标签: html angularjs textarea newline