【发布时间】:2018-05-22 02:52:52
【问题描述】:
我有一个包含换行符 /n 的字符串。尝试显示
字符串。它没有将 /n 作为新行,而是将 '/n' 显示为文本。
$scope.myOutput = " Hello /n"
{{ myOutput | textFormat }}
必填 -> 你好(在 html 页面上)
试过了:
app.filter('textFormat', function() {
return function(x) {
return x.replace(/\\n/g, '<br/>');
}
尝试过 css 样式,例如 white-space: pre;
【问题讨论】:
标签: css angularjs whitespace angular-filters linefeed