javascript - 如何将 bootstrap popover 添加到 Angular ng-repeat

标签 javascript jquery angularjs twitter-bootstrap

我有angular ng-repeat :

<tr data-ng-repeat="employee in employees" ng-class="getClassForEmployee(employee.redRow)" >
    <td>{{employee.last_name}}</td>
    <td>{{employee.first_name}}</td>
    <td>{{employee.departmentName}}</td>
    <td>{{employee.dateContractEnd}}</td>
    <td><a class="btn btn-success btn-sm" href="#employeeCorrect/{{employee.id}}">Редактировать</a></td>
</tr>

AngularJS Controller 中的 JS 代码:

$scope.getClassForEmployee = function (employeeRedRow) {
    if (employeeRedRow) {
        return "alert alert-danger";
    }
};

我想将 bootstrap popover 添加到 red <tr> 。例如:

 <tr id="popover" data-content="something" title="something">

并初始化弹出窗口:

$("tr[id=popover]").popover({placement:"top",trigger:"hover"});

如何动态添加 id、数据内容和标题到红行?

最佳答案

这是一个plunker通过使用 Angular-ui Bootstrap :)

 .... popover="{{ (employee.redRow) ? employee.first_name : '' }}" ....
if employee.redRow is true we add firstname as the poop
else we pass nothing for the poop then its not gonna show the poop

关于javascript - 如何将 bootstrap popover 添加到 Angular ng-repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27166542/

相关文章:

jquery - 使用一个处理程序运行两个 Bootstrap 3 崩溃

javascript - 让 Select2 Gem 与 A​​ctiveAdmin "Add New"按钮一起使用

javascript - AngularJS FormController 中 $addControl 方法的用途是什么?

javascript - 通过 ids 数组过滤 Angular 数据

javascript - 确定模型的当前属性是否与默认属性不同的最简单方法是什么?

javascript - 如何让 jQuery Datepicker 在选择日期后自动按下提交按钮

javascript - 局部函数完成后全局变量失去其值

javascript - 如何使用 Angular 中的 api 调用更新数据库中的数据

javascript - 将值传递给 ajax 函数

css - 如何单独在移动 View 中隐藏 highcharts 中的图例