angularjs - 如何在工具提示中显示 html ng-repeat
问题描述
我正在使用 angularjs,所以我在我的应用程序中添加了一个指令。
app.directive('tooltip', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
$(element)
.attr('title', scope.$eval(attrs.tooltip))
.tooltip({ placement: "right" });
}
}
})
我想显示下面的 html 或类似的东西,我只想在tooltip
<ol>
<li ng-repeat='dt in detail.SelectedCustomers'>{{dt.name}}</li>
</ol>
下面是我所在的桌子tooltip
。
<tr ng-repeat="detail in mainCtrl.lineDetails">
<td><a href="#" data-toggle="tooltip" data-placement="right" data-html="true" tooltip="detail.SelectedCustomers"><i class="fa fa-eye fa-lg" aria-hidden="true"></i></a></td>
</tr>
解决方案
我做了一个小提琴来告诉你你能做些什么
.directive("myTooltip", [ function(){
return{
scope: {
customers:'=myTooltip'
},
link:function(scope, el){
var toDisplay = '';
for(var i = 0; i < scope.customers.length; i++){
toDisplay += scope.customers[i].name+'\n';
}
el.attr('title', toDisplay);
推荐阅读
- git - 预提交挂钩以读取提交消息
- javascript - Replace white spaces only at the beginning and end of a sentence
- php - 如何在 symfony 4 注销时重定向到外部 url
- tomcat - How to different test and production version?
- twitter-bootstrap - Bootstrap 4 table row shadow
- jmeter - 如何从数据库中读取值,例如 jmeter 中的 csv 文件
- javascript - JQuery how to validate file type by getting it's extension using `file.type` function?
- javascript - 如何从使用 ng-repeat 生成的输入字段提交数据并获取所有输入字段的值?
- python - 使用多个进程让工作人员退出队列比使用单个进程更慢
- asp.net - iTextSharp 7 - 保存对话框