<div id="root">
<div ng-controller="SlideShowController">
<slide-show slides="slides"></slide-show>
</div>
</div>
body{
background: #F9F9FA
}
.slideshow {
width: 480px;
height: 360px;
background: #000;
position: relative;
}
.slideshow-slides {
list-style: none;
margin: 0;
padding: 0;
}
.slideshow-slides li {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
margin: 0;
padding: 0;
transition: .2s;
opacity: 0;
}
.slideshow-slides li.active {
opacity: 1;
}
figure {
margin: 0;
padding: 0;
}
figcaption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #fff;
padding: 10px;
}
.slideshow-dots {
position: absolute;
bottom: 0;
left: 0;
right: 0;
text-align: center;
list-style: none;
}
.slideshow-dots li {
display: inline;
margin: 0;
padding: 0;
}
.slideshow-dots a {
cursor: pointer;
display: inline-block;
width: 10px;
height: 10px;
margin: 0 5px;
background: #fff;
border-radius: 10px;
text-indent: -9990px;
opacity: .5;
transition: .3s;
}
.slideshow-dots li.active a {
opacity: 1;
}
var app = angular.module('app', []);
app.controller("SlideShowController", function($scope) {
$scope.slides = [{
imageUrl: "https://i.ytimg.com/vi/MxwjEacvrtY/hqdefault.jpg",
caption: "Allan Allan Al Al Allan"
}, {
imageUrl: "https://pbs.twimg.com/profile_images/2576554888/s8vftzr3j0a9r703xdfn.jpeg",
caption: "Steve Steve Steve"
}];
});
app.directive("slideShow", function() {
return {
restrict: 'E',
transclude: true,
scope: {
slides: '='
},
template: `
<div class="slideshow">
<ul class="slideshow-slides">
<li ng-repeat="slide in slides" ng-class="{ active: $index == activeIndex }">
<figure>
<img ng-src="{{ slide.imageUrl}}" />
<figcaption ng-show="slide.caption">{{ slide.caption }}</figcaption>
</figure>
</li>
</ul>
<ul class="slideshow-dots">
<li ng-repeat="slide in slides" ng-class="{ active: $index == activeIndex }">
<a ng-click="jumpToSlide($index)">{{ $index + 1 }}</a>
</li>
</ul>
</div>
`,
link: function($scope, element, attrs) {
var timer = null;
$scope.activeIndex = 0;
$scope.jumpToSlide = function(index) {
$scope.activeIndex = index;
restartTimer();
};
}
};
});
var root = document.querySelector('#root');
angular.element(root).ready(function() {
angular.bootstrap(root, ['app']);
});
View Compiled
This Pen doesn't use any external CSS resources.