0

I have a Slides Page consisting of 5 Slides. On the 5th Slide I have my "Login Page". Whenever I logout from the Application, I want to be redirected to the 5th Slide.

For Logging Out, I am using an Alert Controller, to provide the user with a confirmation, If he/she wants to logout. When the user Clicks Yes, it will redirect the user to the Slides Page, but It loads the first Slide. I want it to go to my 5th Slide which is my Login Page.

The Buttons for the Alert Controller are below:

{

     text: 'Log Out',
            handler: () => { 
              this.globalService.setToken(null);
              this.navCtrl.navigateRoot('/welcomepage');
            }

},
{

           text: 'No',
            role: 'cancel',
            handler: () => {
            }
}
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263

1 Answers1

0

Update your alertController code to this

{

 text: 'Log Out',
        handler: () => { 
          this.globalService.setToken(null);
          this.navCtrl.navigateRoot('/welcomepage');

          this.events.publish("eventOnSliderVisible", this.splashScreen);
        }},

In your Slider Page,

use below code to move your slides component to 5th slide

ionViewWillEnter() {
this.events.subscribe("eventOnSliderVisible",handler => {
  this.slides.slideTo(5,10);
});

Don't forget to add private events: Events in your class constructor.

Documentation:

'slideTo': (index: number, speed?: number | undefined, runCallbacks?: boolean | undefined) => Promise;

Milan Manwar
  • 374
  • 3
  • 10
  • I tried it, The functionality of the event is working, I checked it by console.log. But I can't get it on the 5th Slide, and I get an Error as in below TypeError: Cannot read property 'slidesPerGroup' of undefined – Usama Parkar Aug 30 '19 at 06:43
  • It'd be better if you share code for the slider page to better identify the problem. However, the solution I've provided here is being used by me right now in production. – Milan Manwar Sep 02 '19 at 05:23