【发布时间】:2023-03-04 09:22:01
【问题描述】:
我有一个国家/地区列表,我正在使用 ng-repeat 填充这些国家/地区列表,一切正常。另外,我正在尝试通过使用引导弹出窗口来显示每个国家/地区的其他详细信息,但它似乎不起作用,所以有人可以帮助我吗?
HTML代码:
<body ng-app="app" ng-controller="my_controller">
<div class="span3 projectCard" ng-repeat="country in all_countries">
<div class="projectCardHeight">
<button class="btn close cardClose" ng-click="deleteCountry(country.id)">×</button>
<div class="cardHeader">Country</div>
<div class="cardBody">{{country.id}}</div>
<div class="cardBody">{{country.title}}</div>
<div class="cardBody"><a href="#" id="pop{{country.id}}" class="btn btn-primary" rel="popover" data-content="This is the <b>body</b> of Popover" data-original-title="Creativity Tuts">pop</a></div>
</div>
</div>
</body>
Javascript 代码:
var app = angular.module("app", []);
app.controller('my_controller', function($scope) {
$scope.all_countries = [
{"id":28,"title":"Sweden"},
{"id":56,"title":"USA"},
{"id":89,"title":"England"}];
});
function deleteCountry(id)
{
alert("Do something");
}
$(document).ready(function () {
$("a[rel=popover]")
.popover({ placement: 'bottom', html: 'true' })
.click(function (e) {
e.preventDefault();
});
});
请参考这个JsFiddle
【问题讨论】:
-
参考引导文档并使用
selector与使用 jQuery.on()相同,以便委托事件处理程序,或将代码包装在指令中 -
你有同样的例子吗?
-
查看 jQuery
on()文档,或此处有关事件委托的数千篇文章之一 -
好的。将检查相同。
标签: angularjs twitter-bootstrap angularjs-ng-repeat