微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Bootstrap popover在AngularJs ng-repeat中不起作用

我有一个国家列表,我正在使用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

解决方法

演示: http://jsfiddle.net/5ww8e/1/

创建一个名为bs-popover的新指令,并将其与ng-repeat一起应用.在bs-popover指令内触发popover方法.

你的js文件加载顺序也是错误的,你应该在bootstrap之前加载jquery.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐