SlideBox to slide automatically after opening


#1

Hi all!

I am new here and just learning about ionic and Angular so would greatly appreciate your help!

I have 2 different slideboxes (lets call them A and B) and I need to go from any slide inside Slidebox A to slide number 1 in Slidebox B. I am using $location.path( path ) to navigate between Slidebox A and Slidebox B however it always starts from Slide 0 and not Slide 1. I cannot default active-slide to 1 because Slidebox B is also accessible from other parts of the app and in those cases it should start from slide 0. So far I’ve tried .slide straight after calling $location.path( path ) but that didn’t work (async call or scope issue?) I’ve also tried attaching .slide to a $location event $locationChangeSuccess but that didn’t work either…

Any suggestions highly appreciated!! Thanks!


#2

bump… no suggestions?


#3

Hey,

did you try to add a optional parameter for your state of slidebox B?

like '/sliderB/1’
1 = Slidenumber

Get the paramvalue in your controller and use $ionicSlideBoxDelegate.slide(slidenumber) http://ionicframework.com/docs/api/service/$ionicSlideBoxDelegate/

Greetz


#4

That’s what i’ve tried using $locationChangeSuccess to call the slide function… But that didn’t really work. I’m using $state.transitionTo instead of $location, maybe I’ll try hooking into its events


#5

Tried with states - still no luck. Here’s what I have:

app.js:

.state('mystate', {
  url: '/mystate',
  templateUrl: 'mypage.html',
  controller: 'MainCtrl',
  data: {
    slideNumber : 1
  }
})

controller:

 $scope.$on('$viewContentLoaded', 
      function(event){
        if ($state.current.data) {
          $scope.slide($state.current.data.slideNumber);
        }
    });

Slide function gets called correctly but there is no sliding happening on the screen…

Instead of sliding to a certain slide - can I just start the slide box from a specific slide programatically?


#6

Just in case someone might have a similar problem - I’ve worked around using active-slide and states. In my controller I added:

if ($state.current.data) {
  $scope.myActiveSlide = $state.current.data.slideNumber;
} else {    
  $scope.myActiveSlide = 0;
}