我有一个国家/地区列表,我正在使用 ng-repeat 填充这些国家/地区列表,一切正常。另外,我试图通过使用引导弹出窗口来显示每个国家/地区内的一些其他详细信息,但它似乎不起作用,所以有人可以帮助我吗?
网页代码:
<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 http://jsfiddle.net/shansubra/4bqgX/54/
Demo: http://jsfiddle.net/5ww8e/1/ http://jsfiddle.net/5ww8e/1/
创建一个名为的新指令bs-popover
并将其与ng-repeat
。扳机popover
里面的方法bs-popover
指示。
另外你的js文件加载顺序是错误的,你应该在引导之前加载jquery。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)