2017-09-26 38 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没有任何东西是来的 –