tomadj
December 28, 2015, 10:52am
1
Hello,
I try to watch the slider of the new directive ion-slides in the last version 1.2.1.
This code does not work.
Any ideas ?
Thank’s
var self = this;
$scope.$watch('vm.slider',function(){
console.log(self.slider);
});
<ion-slides options="vm.optionsSlider" slider="vm.slider">
<ion-slide-page>
page 1
</ion-slide-page>
<ion-slide-page>
page 2
</ion-slide-page>
</ion-slides>
I’m having the same type of issue. Using Angular 1.X with Ionic 1.2 I can’t get the $scope.$watch to work. Can’t get the change function to work either …
<ion-slides options="options" slider="slider" change="onSlideChanged($event)">
None of these functions are firing anything.
$scope.onSlideChanged = function(slider) {
console.log('Slide changed', slider);
console.log("active index", slider.activeIndex);
}
$scope.changed = function(slider) {
console.log('Slide changed', slider);
console.log("active index", slider.activeIndex);
}
$scope.$watch($scope.slider, function(slider, slider2){
console.log(slider);
console.log(slider2);
})
Have a looky here, this helped me.
Tried a watch on the slider. Didnt work. What worked for me is this.
$scope.swiperOptions = { /* Whatever options */ effect: 'slide', initialSlide: 0, /* Initialize a scope variable with the swiper */ onInit: function(swiper){ $scope.swiper = swiper; }, onSlideChangeEnd: function(swiper){ console.log('The active index is ' + swiper.activeIndex); } };
HTML
<ion-slides slider="swiper" options="swiperOptions"> <ion-slide-page><h1>TEST HEADER 1</h1></ion-slide-page> <ion-slide-page><h1>TEST HEADE…