html - 如何在 Angular 中显示两个连续的空间?

标签 html angular

更新:Chris 和 Mark 的两种方法都有效。

我正在使用 Angular 2。我尝试在页面中的 ab 之间显示两个连续的空格。我已经尝试了所有这些,但都没有用:

{{text}}

text = "a\00a0\00a0b";
text = `a\00a0\00a0b`;
text = "a  b";
text = `a  b`;
text = "a  b";
text = `a  b`;

我怎样才能让它发挥作用?

最佳答案

绑定(bind)到 DOM 属性 innerHTML 而不是 DOM 属性 textContent(这是 {{}} 绑定(bind)到的):

<span [innerHTML]="text"></span>

text = "a&nbsp;&nbsp;b";

关于html - 如何在 Angular 中显示两个连续的空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35247325/

相关文章:

html - 响应式设计混合内容列

javascript - 从事件监听器 OnClick 中排除按钮

javascript - Angular 7 分量

html - css property 属性不工作,因为它应该正常工作

html - CSS - 包括页脚的可滚动侧边栏

angular - Azure存储javascript客户端: how to track upload progress using Ionic/Angular?

angular - HTTP post 请求不断发送空主体

angular - 如何在 Angular 中使用 google 距离矩阵 API

javascript - 在 Javascript 中以 px 为单位测量 ex

javascript - 复制模块后无法读取未定义的属性 'visitExpression'