如何在工具提示中显示html ng-repeat

问题描述 投票:0回答:1

我正在使用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>
angularjs html-table angularjs-ng-repeat tooltip
1个回答
1
投票

我做了一个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);
© www.soinside.com 2019 - 2024. All rights reserved.