forked from angular-ui/bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact(carousel): Change to using active binding for current slide
- Loading branch information
Showing
6 changed files
with
159 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
<div ng-controller="CarouselDemoCtrl"> | ||
<carousel current-index="selected" interval="5000"> | ||
<slide ng-repeat="s in slides" active="s.active"> | ||
<img ng-src="{{s.image}}" style="margin:auto;"> | ||
<carousel interval="myInterval"> | ||
<slide ng-repeat="slide in slides" active="slide.active"> | ||
<img ng-src="{{slide.image}}" style="margin:auto;"> | ||
<div class="carousel-caption"> | ||
<h4>Slide {{$index}}</h4> | ||
<p>{{s.text}}</p> | ||
<p>{{slide.text}}</p> | ||
</div> | ||
</slide> | ||
</carousel> | ||
Select slide: | ||
<a ng-repeat="i in slides" ng-click="selectSlide($index)" class="btn btn-mini">{{$index}}</a> | ||
<br /><a class="btn btn-primary" ng-click="addSlide()">Add Slide</a> | ||
<div class="row-fluid"> | ||
<div class="span6"> | ||
<ul> | ||
<li><a class="btn btn-primary" ng-click="addSlide()">Add Slide</a></li> | ||
<li ng-repeat="slide in slides"> | ||
{{$index}}: {{slide.text}} | ||
<a ng-click="slide.active = true">[select]</a> | ||
<a ng-click="slides.splice($index, 1)">[remove]</a> | ||
<span ng-show="slide.active" style="color:green;">✓</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="span6"> | ||
Interval, in milliseconds: <input ng-model="myInterval"> | ||
<br />Enter a negative or non-number to stop the interval. | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
function CarouselDemoCtrl($scope) { | ||
var slides = $scope.slides = [ | ||
{image: 'http://placekitten.com/325/200',text: 'Kitten.'}, | ||
{image: 'http://placekitten.com/275/200',text: 'Kitty!'}, | ||
{image: 'http://placekitten.com/375/200',text: 'Cat.'}, | ||
{image: 'http://placekitten.com/250/200',text: 'Feline!'} | ||
$scope.myInterval = 5000; | ||
$scope.slides = [ | ||
{image: 'http://placekitten.com/200/200',text: 'Kitten.'}, | ||
{image: 'http://placekitten.com/225/200',text: 'Kitty!'}, | ||
{image: 'http://placekitten.com/250/200',text: 'Cat.'}, | ||
{image: 'http://placekitten.com/275/200',text: 'Feline!'} | ||
]; | ||
$scope.selectSlide = function(i) { | ||
$scope.selected = i; | ||
}; | ||
$scope.addSlide = function() { | ||
slides.push({ | ||
image: 'http://placekitten.com/'+(200+20*slides.length)+'/200', | ||
text: ['More','Extra','Additional','Surplus'][Math.floor(Math.random()*4)] + ' ' + | ||
['Cats', 'Kittys', 'Felines', 'Cute Things'][Math.floor(Math.random()*4)] | ||
$scope.slides.push({ | ||
image: 'http://placekitten.com/'+(200+25*Math.floor(Math.random()*4))+'/200', | ||
text: ['More','Extra','Lots of','Surplus'][Math.floor(Math.random()*4)] + ' ' + | ||
['Cats', 'Kittys', 'Felines', 'Cutes'][Math.floor(Math.random()*4)] | ||
}); | ||
}; | ||
} |
Oops, something went wrong.