我正在使用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>
我做了一个fiddle,告诉你如何做
.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);