2017-09-26 39 views
1

我也在使用tootltiptrusashtml,但是文本顯示爲不能解析爲html的字符串。HTML標籤不能在uib-tooltip裏面工作

HTML:

<label uib-tooltip="{{TooltipText}}" 
     tooltip-enable="!showEditHours" 
     for="IsAttested" 
     ng-class="{'Cursor_Auto': !showEditHours}">Text</label> 

控制器:

$scope.ad = { 'text': 'This attestation is editable only when the <b> Hours of the Accounting Firm of the Issuer </b> section has been enabled for edit. Please click on the Edit <b> Hours of the Accounting Firm of the Issuer </b> button.' }; 
$scope.TooltipTextAttestationFinalName = $sce.trustAsHtml($scope.ad.text); 

回答

0

你有兩個選擇。

首先是使用指令uib-tooltip-html,根據documentation根據documentation獲得一個表達式,其計算結果爲一個html字符串。這可能是你在找什麼:

<label uib-tooltip-html="TooltipText" 
    tooltip-enable="!showEditHours" 
    for="IsAttested" 
    ng-class="{'Cursor_Auto': !showEditHours}">Text</label> 

另一種是到uib-tooltip-template,這需要解析爲一個模板路徑的表達式。

+1

謝謝,我是使用UIB-提示-HTML中表述,再次多虧的原因。 –

+0

背後的原因是什麼? –

+1

'uib-tooltip-html'指令採用一個角度表達式作爲輸入,但是{{someVar}}'實際上在將表達式傳遞給指令之前計算表達式,所以指令只會得到一個字符串並嘗試再次評估它(並失敗)。作爲一個例子,如果你聲明瞭'$ scope.someVar ='這是一個字符串''並且像這樣傳遞它'uib-tooltip-html ='{{someVar}}'',那麼在幕後,工具提示指令嘗試有點像這樣使用它:'$ scope ['這是一個字符串']',但這顯然不起作用。在評論中解釋清楚有點困難。 :-) –

0

試試這個

<label uib-tooltip-html="{{TooltipText}}" 
     tooltip-enable="!showEditHours" 
     for="IsAttested" 
     ng-class="{'Cursor_Auto': !showEditHours}">Text</label 

控制器

$scope.ad = { 'text': 'This attestation is editable only when the <b> Hours of the Accounting Firm of the Issuer </b> section has been enabled for edit. Please click on the Edit <b> Hours of the Accounting Firm of the Issuer </b> button.' }; 
$scope.TooltipTextAttestationFinalName = $sce.trustAsHtml($scope.ad.text); 
+0

我實際上在嘗試之前,當我使用html沒有任何東西是來的 –