2017-06-21 46 views
1

我正在使用angular 2和ng bootstrap彈出窗口功能。以下是我的html。我有infoIconText變量有一些新行\ n字符。但是,當我看到popover文本時,我仍然無法看到新行。我如何設計popover文字?有什麼建議麼?ngbpopover文本的新行

<i class="fa fa-info-circle" ngbPopover="{{infoIconText}}" triggers="mouseenter:mouseleave" aria-hidden="true"></i> 

我infoIconText如下:

this.infoIconText = "This is line 1." + 
     "\nThis is line2"; 

回答

1

我能夠創建一個模板,且引用該模板來解決這個問題。

<ng-template #popContent>Line1<br>Line2</ng-template> 

<i class="fa fa-info-circle info-icon-background popover-content" [ngbPopover]="popContent" placement="top" triggers="mouseenter:mouseleave" aria-hidden="true"></i> 
+0

這是正確的做法! –