关于textarea
和文本预览,我有一个问题。它不承认Enter
按钮是换行符。有什么办法使这个预览正确吗?
编辑:
我想要这个文本自动更改行,当它不适合,而不是h-卷轴。
答案:
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
发布于 2016-06-20 08:36:42
您可以在从<pre>
打印文本时使用textarea
标记,它将在textarea
中输入文本时反映所有新行。
只需在内容之前使用<pre>
。
<pre> Text Content From text Area</pre>
发布于 2016-06-20 09:50:37
http://plnkr.co/edit/gZM1173PNweJzcBEutTw?p=preview
您需要使用ngSanitize
并允许参数接受带有$sce.trustAsHtml()的html条目;
html
<textarea ng-model="text" ng-change="change()"></textarea>
<p ng-bind-html='text'></p>
js
$scope.change = function(){
$scope.text = $sce.trustAsHtml($scope.text);
}
css
{white-space: pre}
您将能够使用换行符呈现和保存文本。
https://stackoverflow.com/questions/37917801
复制相似问题