use*_*255 8 twitter-bootstrap angularjs 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>
Run Code Online (Sandbox Code Playgroud)
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();
});
});
Run Code Online (Sandbox Code Playgroud)
请参考这个JsFiddle
Dai*_*wei 14
演示:http://jsfiddle.net/5ww8e/1/
创建一个名为的新指令bs-popover并将其与之一起应用ng-repeat.指令popover内的触发方法bs-popover.
你的js文件加载顺序也是错误的,你应该在bootstrap之前加载jquery.
| 归档时间: |
|
| 查看次数: |
14308 次 |
| 最近记录: |