[英]AngularJS : ng-bind-html inside a uib-tooltip-html
I have to show a tooltip in my UI. 我必须在用户界面中显示工具提示。 I am using angularjs in UI side. 我在UI端使用angularjs。
Please see the code below. 请参见下面的代码。
<i class="fa fa-info-circle f18 darkgray hover pointer" uib-tooltip-html="'<div class=fw-600>Reason:</div>"+obj.comments+"'" tooltip-class="white-blue-tooltip"></i>
But I am getting error when the value of obj.comments = Canceled via 'View Group'
. 但是当obj.comments = Canceled via 'View Group'
的值时,我得到了错误。 Please see the error below. 请查看以下错误。
Error: [$parse:syntax] Syntax Error: Token 'View' is an unexpected token at column 49 of the expression ['<div class=fw-600>Reason:</div>cancelling via 'View Group''] starting at [View Group''].
This is because of the single quote present in the value (Canceled via 'View Group'). 这是因为值中存在单引号(通过“视图组”取消)。
In order to solve this I have used ng-Sanitize
as described in the following link https://www.w3schools.com/angular/ng_ng-bind-html.asp 为了解决这个问题,我使用了ng-Sanitize
,如以下链接https://www.w3schools.com/angular/ng_ng-bind-html.asp中所述
Now my code look like below 现在我的代码如下所示
<i class="fa fa-info-circle f18 darkgray hover pointer" uib-tooltip-html="'<div class=fw-600>Reason:</div> ng-bind-html="+obj.comments+"'" tooltip-class="white-blue-tooltip"></i>
But I am getting output like 但是我得到的输出像
Reason:
ng-bind-html=Canceled via 'View Group'
I have added 'ngSanitize'
in my controller and loaded the angular.min.js
and angular-sanitize.js
in the page, is there anything missing here. 我在控制器中添加了'ngSanitize'
,并在页面中加载了angular.min.js
和angular-sanitize.js
,这里缺少任何内容。
Appreciates any help. 感谢任何帮助。
You have to use $sce
service. 您必须使用$sce
服务。 Please look into following link. 请查看以下链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.