繁体   English   中英

AngularJS:uib-tooltip-html内的ng-bind-html

[英]AngularJS : ng-bind-html inside a uib-tooltip-html

我必须在用户界面中显示工具提示。 我在UI端使用angularjs。

请参见下面的代码。

<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>

但是当obj.comments = Canceled via 'View Group'的值时,我得到了错误。 请查看以下错误。

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''].

这是因为值中存在单引号(通过“视图组”取消)。

为了解决这个问题,我使用了ng-Sanitize ,如以下链接https://www.w3schools.com/angular/ng_ng-bind-html.asp中所述

现在我的代码如下所示

<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>

但是我得到的输出像

Reason: 
ng-bind-html=Canceled via 'View Group'

我在控制器中添加了'ngSanitize' ,并在页面中加载了angular.min.jsangular-sanitize.js ,这里缺少任何内容。

感谢任何帮助。

您必须使用$sce服务。 请查看以下链接。

Angularjs Sce

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM