我也在使用tootltip
和trusashtml
,但是文本显示为不能解析为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);
谢谢,我是使用UIB-提示-HTML中表述,再次多亏的原因。 –
背后的原因是什么? –
'uib-tooltip-html'指令采用一个角度表达式作为输入,但是{{someVar}}'实际上在将表达式传递给指令之前计算表达式,所以指令只会得到一个字符串并尝试再次评估它(并失败)。作为一个例子,如果你声明了'$ scope.someVar ='这是一个字符串''并且像这样传递它'uib-tooltip-html ='{{someVar}}'',那么在幕后,工具提示指令尝试有点像这样使用它:'$ scope ['这是一个字符串']',但这显然不起作用。在评论中解释清楚有点困难。 :-) –