我有一个国家列表,我正在使用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/5ww8e/1/
创建一个名为bs-popover的新指令,并将其与ng-repeat一起应用.在bs-popover指令内触发popover方法.