gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:19:54 25 4
gpt4 key购买 nike

我有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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com