Angular carousel not working
Bower.json file content:
{
"name": "blue",
"version": "0.0.0",
"dependencies": {
"angular": "1.3.1",
"json3": "~3.3.1",
"es5-shim": "~3.1.0",
"bootstrap-sass-official": "~3.2.0",
"angular-sanitize": "1.3.1",
"angular-animate": "1.3.1",
"angular-touch": "1.3.1",
"restangular": "~1.4.0",
"ui-bootstrap": "~0.11.2",
"ui-router": "~0.2.11",
"ng-grid": "~2.0.13",
"angular-bootstrap": "~0.11.2",
"angular-carousel": "~0.3.5"
},
"devDependencies": {
"angular-mocks": "1.3.1",
"angular-scenario": "1.3.1"
},
"appPath": "app"
}
Viewing (with or without repeater):
<div class="attachments col-lg-12">
<ul rn-carousel class="image">
<li ng-repeat="image in email.value.files">
<div class="layer">{{ image }}</div>
</li>
</ul>
<ul rn-carousel class="image">
<li>slide #1</li>
<li>slide #2</li>
<li>slide #3</li>
</ul>
</div>
email.value.files
:
["http://localhost:1337/files/105/Protein_5.png","http://localhost:1337/files/105/Protein_4.png","http://localhost:1337/files/105/Protein_3.png","http://localhost:1337/files/105/Protein_2.png"]
No errors on console, css file is present, root element of directive is 0px-0px when using validate element.
+3
source to share
1 answer
I tried below code and it worked.
<!DOCTYPE html>
<html ng-app>
<head>
<title>ng Crousal</title>
<style type="text/css">
#slides_control > div{
height: 200px;
}
img{
margin:auto;
width: 400px;
}
#slides_control {
position:absolute;
width: 400px;
left:50%;
top:20px;
margin-left:-200px;
}
</style>
</head>
<body>
<div ng-app="app">
<div ng-controller="CarouselDemoCtrl" id="slides_control">
<div>
<carousel interval="myInterval">
<slide ng-repeat="slide in slides" active="slide.active">
<img ng-src="{{slide.image}}">
<div class="carousel-caption">
<h4>Slide {{$index+1}} : #</h4>
</div>
</slide>
</carousel>
</div>
</div>
</div>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script>
angular.module('app', ['ui.bootstrap']);
function CarouselDemoCtrl($scope) {
$scope.myInterval = 3000;
$scope.slides = [
{
image: 'http://lorempixel.com/400/200/'
},
{
image: 'http://lorempixel.com/400/200/food'
},
{
image: 'http://lorempixel.com/400/200/sports'
},
{
image: 'http://lorempixel.com/400/200/people'
}
];
}
</script>
</body>
</html>
-1
source to share