Hello,
I’m sorry I wasn’t unable to find a codepen with this behavior…
I’m using a button to change slides with a forced index and this called function :
$scope.changeSlide = function(index){
console.info("changeSlide");
$scope.slideIndex = index;
$ionicSlideBoxDelegate.slide(index);
console.log($scope);
};
This is working properly when I open the view, but when I’m getting back to it on a cached instance the drag slide is working, but my button doesn’t work anymore and the $ionicSlideBoxDelegate.slide(index); is undefined…
I think I lost my $ionicSlideBoxDelegat, any thought how to get it back ? Thank you.
It occurs that I have now 2 instance os $ionicSlideBoxDelegate :
DelegateService {_instances: Array[2], update: function, slide: function, select: function, enableSlide: function…}_instances: Array[2]
0: child$$delegateHandle: “slideRelations”$$filterFn: function () {autoPlay: function (newDelay) {count: function () {currentIndex: function () {enableSlide: function (shouldEnable) {kill: function () {load: function () {loop: function (value) {next: function () {prev: function () {previous: function () {select: function (to, speed) {selected: function () {setup: function () {slide: function (to, speed) {slideIsDisabled: falseslidesCount: function () {start: function () {stop: function () {update: function () {proto: Surrogate
1: child$$delegateHandle: “slideRelations”$$filterFn: function () {autoPlay: function (newDelay) {count: function () {currentIndex: function () {enableSlide: function (shouldEnable) {kill: function () {load: function () {loop: function (value) {next: function () {prev: function () {previous: function () {select: function (to, speed) {selected: function () {setup: function () {slide: function (to, speed) {slideIsDisabled: falseslidesCount: function () {start: function () {stop: function () {update: function () {proto: Surrogatelength: 2__proto__: Array[0]proto: DelegateInstance
I implemented a timeout around the $ionicSlideBoxDelegate.
$timeout(function() {
if(!$scope.slideIndex){
$scope.slideIndex = 0;
}
console.info("$ionicSlideBoxDelegate", $scope, $ionicSlideBoxDelegate);
$ionicSlideBoxDelegate.$getByHandle('slideRelations').update();
$ionicSlideBoxDelegate.$getByHandle('slideRelations').slide($scope.slideIndex);
}, 100);
And within a cached view I still have this error :
Delegate for handle “slideRelations” could not find a corresponding element with delegate-handle=“slideRelations”! update() was not called!
Possible cause: If you are calling update() immediately, and your element with delegate-handle=“slideRelations” is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to update() and try again.