twitter-bootstrap 在 uib-tooltip-html 上动态添加内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34898126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add content on uib-tooltip-html dynamically
提问by Petran
I want to combine content on a uib-tooltip-html like the following example
我想像下面的例子一样在 uib-tooltip-html 上组合内容
app.controller("testController", function($scope, $http, $interval, $sce) {
$scope.text = $sce.trustAsHtml('<div>Some text</div>');
});
<p style="margin-top: 5em;" uib-tooltip-html="<div>text moretext</div>" >
A Thing With an HTML Tooltip
</p>
http://plnkr.co/edit/KWoByXuzejuRwmFmwgqJ?p=previewis that possible ?
采纳答案by keshav
try this
试试这个
uib-tooltip-html="'<div>'+'text moretext'+'</div>'"
inside your code.
在您的代码中。
回答by Felippe Duarte
I was trying to dynamically update the tooltip, but I can't figure out how to use a function with parameters. So I did this:
我试图动态更新工具提示,但我不知道如何使用带参数的函数。所以我这样做了:
View
看法
<td ng-mouseover="getTooltip(model)" data-uib-tooltip-html="tooltip" ..>{{ some.data }}</td>
Controller
控制器
$scope.tooltip = '';
$scope.getTooltip = function(model) {
var tooltip;
if(model.somedata == 'x') {
tooltip = 'some content';
}
else {
tooltip = 'some other content';
}
$scope.tooltip = $sce.trustAsHtml('<div>'+tooltip+'</div>');
}
hope it helps someone.
希望它可以帮助某人。

