Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Commit 49c51ed

Browse files
author
Julien Bouquillon
authored
Merge pull request #433 from hackeo1/master
Add variable to get slides if no ng-repeat is used
2 parents adf0aff + 3b9b363 commit 49c51ed

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ angular.module('MyApp', ['angular-carousel']);
6262

6363
## Directive options :
6464
- `rn-carousel-index` two way binding integer to control the carousel position (0-indexed)
65+
- `rn-rn-carousel-html-slides`: two way binding array to get slides if no ng-repeat was used (slides array)
6566
- `rn-carousel-buffered` add this attribute to enable the carousel buffering, good to minimize the DOM (5 slides)
6667
- `rn-carousel-controls` add this attribute to enable builtin prev/next buttons (you can override by CSS)
6768
- `rn-carousel-auto-slide` add this attribute to make the carousel slide automatically after given seconds (default=3)

dist/angular-carousel.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Angular Carousel - Mobile friendly touch carousel for AngularJS
3-
* @version v1.0.2 - 2016-11-25
3+
* @version v1.0.2 - 2017-08-03
44
* @link http://revolunet.github.com/angular-carousel
55
* @author Julien Bouquillon <julien@revolunet.com>
66
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -458,6 +458,25 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
458458
angular.forEach(getSlidesDOM(), function(node, index) {
459459
currentSlides.push({id: index});
460460
});
461+
if (iAttributes.rnCarouselHtmlSlides) {
462+
var updateParentSlides = function(value) {
463+
slidesModel.assign(scope.$parent, value);
464+
};
465+
var slidesModel = $parse(iAttributes.rnCarouselHtmlSlides);
466+
if (angular.isFunction(slidesModel.assign)) {
467+
/* check if this property is assignable then watch it */
468+
scope.$watch('htmlSlides', function(newValue) {
469+
updateParentSlides(newValue);
470+
});
471+
scope.$parent.$watch(slidesModel, function(newValue, oldValue) {
472+
if (newValue !== undefined && newValue !== null) {
473+
newValue = 0;
474+
updateParentIndex(newValue);
475+
}
476+
});
477+
}
478+
scope.htmlSlides = currentSlides;
479+
}
461480
}
462481

463482
if (iAttributes.rnCarouselControls!==undefined) {

0 commit comments

Comments
 (0)