簡體   English   中英

ngb popover 不呈現 html 編碼

[英]ngb popover not rendering html encoding

我需要在 ngbPopover 中渲染一些文本,我可以做到。
這里的問題是我需要在文本之間換行。

我嘗試使用 <br>, \\n, \ nothings 對我有用 <br> 按原樣顯示,對於 \\n 和 \ 我在屏幕上看不到任何影響。

以下是我的代碼供參考。

html

<ng-template #subCoveragePopup>
   <div class="sub-coverage-tooltip">
      <div class="details">
        <div *ngFor="let subCov of getSubCoverageDescription(quoteCoverage.coverage)">
          <div class="title">{{subCov.code}}</div>
          <div class="">{{subCov.name}}</div>
        </div>
      </div>
   </div>
</ng-template>

subCov.name我通過 angular 得到以下文本 ->

測試:這是第 1 行\ 這是第 2 行

要么

測試:這是第 2 行 \\n 這是第 2 行

要么

測試:這是第 <BR> 這是第 2 行

使用所有三個選項,我無法顯示換行符。 有什么我想念的嗎?

將 css 樣式添加到同一個 div :

<ng-template #subCoveragePopup>
   <div class="sub-coverage-tooltip">
      <div class="details">
        <div *ngFor="let subCov of getSubCoverageDescription(quoteCoverage.coverage)">
          <div class="title">{{subCov.code}}</div>
          <div class="splitLine">{{subCov.name}}</div>
        </div>
      </div>
   </div>
</ng-template>
.splitLine {
    style="white-space: pre;"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM