Skip to content

Commit 551f64c

Browse files
committed
Access slider
1 parent 7fe987c commit 551f64c

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

Diff for: js/angular/directive/slides.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function($animate, $timeout) {
4141
restrict: 'E',
4242
transclude: true,
4343
scope: {
44-
options: '='
44+
options: '=',
45+
slider: '='
4546
},
4647
template: '<div class="swiper-container">' +
4748
'<div class="swiper-wrapper" ng-transclude>' +
@@ -84,6 +85,7 @@ function($animate, $timeout) {
8485
var slider = new ionic.views.Swiper($element.children()[0], newOptions);
8586

8687
_this.__slider = slider;
88+
$scope.slider = _this.__slider;
8789

8890
$scope.$on('$destroy', function() {
8991
slider.destroy();

Diff for: test/html/slides.html

+41-13
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,36 @@
1616
<ion-title>Hello</ion-title>
1717
</ion-header-bar>
1818
<ion-content class="padding">
19-
<ion-slides options="options">
19+
<ion-slides options="options" slider="data.slider">
2020
<ion-slide-page>
21-
<h2>Journey to HD 219134 b</h2>
22-
<p>
23-
This app will prepare you for your journey through the galaxy
24-
to HD 219134 b, an exoplanet 21 lightyears away from our home on Earth.
25-
</p>
26-
<p>
27-
<img src="exoplanet.jpg" style="max-width: 100%" />
28-
</p>
29-
<div style="text-align: center">
30-
<small style="font-style: italic">An artist's rendering of your new home.</small>
31-
</div>
21+
<ion-content>
22+
<h2>Journey to HD 219134 b</h2>
23+
<p>
24+
This app will prepare you for your journey through the galaxy
25+
to HD 219134 b, an exoplanet 21 lightyears away from our home on Earth.
26+
</p>
27+
<p>
28+
<img src="exoplanet.jpg" style="max-width: 100%" />
29+
</p>
30+
<p>
31+
<img src="exoplanet.jpg" style="max-width: 100%" />
32+
</p>
33+
<p>
34+
<img src="exoplanet.jpg" style="max-width: 100%" />
35+
</p>
36+
<p>
37+
<img src="exoplanet.jpg" style="max-width: 100%" />
38+
</p>
39+
<p>
40+
<img src="exoplanet.jpg" style="max-width: 100%" />
41+
</p>
42+
<p>
43+
<img src="exoplanet.jpg" style="max-width: 100%" />
44+
</p>
45+
<div style="text-align: center">
46+
<small style="font-style: italic">An artist's rendering of your new home.</small>
47+
</div>
48+
</ion-content>
3249
</ion-slide-page>
3350
<ion-slide-page>
3451
<h2>Before launch</h2>
@@ -98,10 +115,21 @@ <h2>Life on HD 219134 b</h2>
98115
</ion-pane>
99116
<script>
100117
angular.module('slidesTest', ['ionic'])
101-
.controller('MyCtrl', ['$scope', '$interval', function($scope, $interval) {
118+
.controller('MyCtrl', ['$scope', '$interval', '$timeout', function($scope, $interval, $timeout) {
102119
$scope.options = {
103120
loop: true
104121
}
122+
123+
$scope.data = {};
124+
125+
$scope.$watch('data.slider', function(nv, ov) {
126+
$scope.slider = $scope.data.slider;
127+
})
128+
129+
$timeout(function() {
130+
//$scope.slider.slideNext();
131+
}, 1000)
132+
105133
/*
106134
$scope.extraSlides = [];
107135
var i = 0;

0 commit comments

Comments
 (0)