javascript - 新行和制表符以 Angular 添加到我的字符串中

标签 javascript css angularjs html angular-material

我的 html 中有以下 div:

<div flex style="white-space:pre-wrap;">
    {{c.display}}
</div>

c.display 设置如下:

$scope.c.display = "foo\nbar\n\tfoobar";

输出如下所示:

enter image description here

html 源代码如下所示:

enter image description here

如果我使用开发工具将 Chrome 上的源更改为:

enter image description here

我一直得到我想要的,就是这样:

enter image description here

那么,为什么会发生这种情况,我该如何阻止它呢?

最佳答案

如何从 div 中删除空格?

<div flex style="white-space:pre-wrap;">{{c.display}}</div>

关于javascript - 新行和制表符以 Angular 添加到我的字符串中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31571673/

相关文章:

javascript - $ (':target' ) 在 Internet Explorer 11 中返回长度 0

javascript - 在使用 CDN 版本的 CKeditor 时尝试加载表情符号插件...CORS 问题

javascript - 冗余 Amazon S3/Rails

html - 如何在 IE 中隐藏 clipPath

html - Bootstrap 使列适合

javascript - 更新范围内部对象

javascript - Angular JS 当前范围是什么?

javascript - 如何从我的 video.js 播放器中监听 "timeupdate"事件?

css - 浏览器不呈现 CSS ID 样式(覆盖在 Firebug 中显示正确)

angularjs - 在AngularJS中使用 'ng-style'添加背景图片