angular - 在 concat() 字符串中添加新行 - Angular 4

标签 angular typescript

使用 Angular 4 - 以下代码片段位于我的 typescript 文件中。

this.tabTitle = "Project Name: " + this.currentProjectRevision.ProjectInformation[0].ProjectName;

这会获取项目名称的值并将其与项目名称连接起来:

       this.tabTitle = this.tabTitle.concat('/n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

以上代码获取第一行代码值并将其与报价 ID: 连接起来,并添加报价 ID 的值。

运行时,输出如下。项目名称:test/n 引用ID:0000001

上述实际值附加到以下代码中。 项目名称:bvn xbn/n 报价ID:1000016

我希望报价 ID 在新行开始。 我试过输入 <br/> , <br>以及/n 都不会成功。它们都作为字符串添加。

到目前为止我尝试过的代码

this.tabTitle = this.tabTitle.concat('<br/>' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

this.tabTitle = this.tabTitle.concat('<br>' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

this.tabTitle = this.tabTitle.concat('/n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

任何帮助将不胜感激。

最佳答案

您可以将类附加到具有属性 white-space: pre; 的元素。如果您使用的是 /n,这将为您换行。

关于angular - 在 concat() 字符串中添加新行 - Angular 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50496780/

相关文章:

angular - ngx-leaflet:如何添加自定义控件?

angular - Safari、Iphone 上的 Firebase 电话身份验证问题

typescript - 如何在 e2e 测试中测试包含异常过滤器的 websockets(网关)

node.js - 如何稳定 {Node} npm 依赖系统?

javascript - Angular2 - 注入(inject)@Injectable

javascript - Ionic 2 - *ng用于值之间的随机洗牌

node.js - 使用 keycloak-connect + typescript - 使用需要特定参数的函数,但我不知道它指的是什么

javascript - 我可以使用 TypeScript 在 axios.get 方法中的泛型类型中指定任何类型

typescript - 我可以在构建时将参数传递给 angular-cli

angular - "SyntaxError: Unexpected token export(…)"