arc*_*gel 3 javascript jquery carousel twitter-bootstrap angularjs
我知道在许多问题中已经提到过这个问题,但是jQuery没有加载的最常见的答案对我来说不起作用.看来我的jQuery正在正确加载(版本1.10.2).我试图运行以下代码(甚至在控制台中尝试,因此加载问题不会保留):
$('.carousel').on('mouseenter',function(){ $( this ).carousel();})
Bootstrap旋转木马本身工作正常.只是当我试图动态初始化它时,它无法正常工作.(我刚开始使用angular和bootstrap,所以我可能会在这里找到一些非常简单的东西.)我正在为我的应用程序使用角度js和bootstrap.
编辑:这是我的HTML代码:
<div class="row" ng-controller="ItemGallery" style="padding-top:30px;">
<div class="col-md-4 item_card" ng-repeat="item in item_array">
<a href="{{'/product/id='+item.product_id}}" class="thumbnail">
<div id="{{'carousel_'+item.product_id}}" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="{{item.thumbnail}}" alt="{{item.product_title}}" class="img-responsive product-image"/>
</div>
<div class="item">
<img src="{{item.nutrition_thumbnail}}" alt="{{item.product_title}}" class="img-responsive nutri-image"/>
</div>
</div>
</div>
<div class="caption post-content">
<h4 class="h_no_margin">
<p class="pull-left title">{{item.product_title.toLowerCase() }}</p>
<p class="text-right">${{item.price}}</p>
</h4>
<small>
{{item.product_desc}}
</small>
</div>
</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
角度代码:
var app = angular.module('item_gallery', []);
app.controller('ItemGallery', function($http, $scope, $location) {
$http.get("/product/list")
.success(function(response) {
$scope.item_array = response.response;
});
});
Run Code Online (Sandbox Code Playgroud)
我用bower来处理依赖关系.
{
"name": "nutrinext",
"version": "0.0.0",
"dependencies": {
"angular": "~1.3.1",
"angular-bootstrap": "~0.11.2",
"angular-timeago": "~0.1.3",
"angular-ui-router": "~0.2.11",
"ngstorage": "~0.3.0",
"bootstrap": "~3.3.0",
"bootstrap-markdown": "~2.7.0",
"jquery": "1.10.2",
"fastclick": "~1.0.3",
"fontawesome": "~4.2.0",
"pubnub": "~3.6.4"
},
"devDependencies": {},
"resolutions": {
"angular": "~1.3.1",
"bootstrap": "~3.3.0"
}
}
Run Code Online (Sandbox Code Playgroud)
Sau*_*abh 10
我遇到了同样的问题,我遗漏的内容包括bootstrap.js在我的内容中index.html,并且在添加后它工作了.
<script type="text/javascript" src="components/bootstrap/dist/js/bootstrap.js"></script>
Run Code Online (Sandbox Code Playgroud)