How to redirect first time selected page in two pages?


#1

I have two page in intro time homepage1 and homepage2, if i select homepage1 and i start again app at that time opening homepage1, but i wanna try when i select homepage2 and showing me homepage1, any idiea how can i do this. Please help me:(. i am using this example.


#2

Your question is not clear.
please try to be more precise.
And if you want to open home page 2 then try changing the code:

  navHome() {
    this.navCtrl.setRoot(HomePage2);
  }

#3

When I start my application first time, it’s time to there i have two pages page1 and page 2 and if i select page 2 and i start the second time app at time coming first page on my pages.


#4

hi here i make video on my error, you can see here i have two pages him and her, when i click on her and go on women homepage but when i start again app there showing me man homepage. so any idiea how to do this.
Video Link Here


#5

Show me your code!! both .html and .ts ( homepage )


#6

Here i have two home page,
and one intro page name as welcomePage

welcome.html

<!--
  Generated template for the WelcomePage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-content padding class="page-welcome">
	<ion-toolbar>
        <ion-buttons end>
          <button ion-button color="primary" (click)="skipPage()">Skip</button>
        </ion-buttons>
      </ion-toolbar>
      <h2 class="welcome-title">Welcome to Workout</h2>
      <p>Lets start with tailoring Workout for you.</p>
	  <br>
	  <br>
	  <br>
	  <p>Who do you want guide you?</p>
	  
	  <div class="welcome_img">
	  <a (click)="menPage();"><img src="assets/imgs/new_men.png" class="welcome-image"/></a>
	  <p>Him</p>
	  </div>
	  
	  <div class="welcome_img">
	  <a (click)="womenPage();"><img src="assets/imgs/new_women.png" class="welcome-image"/></a>
	  <p>Her</p>
	  </div>
</ion-content>

welcome.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { WomanSlidePage } from '../woman-slide/woman-slide';
import { ManSlidePage } from '../man-slide/man-slide';
import { HomePage } from '../home/home';
import { WomanHomePage } from '../woman-home/woman-home';

/**
 * Generated class for the WelcomePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-welcome',
  templateUrl: 'welcome.html',
})
export class WelcomePage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad WelcomePage');
  }
  
	womenPage(){
		this.navCtrl.push(WomanSlidePage);
		this.navCtrl.setRoot(HomePage);
	}
	
	menPage(){
		this.navCtrl.push(ManSlidePage);
		this.navCtrl.setRoot(WomanHomePage);
	} 
	
	skipPage(){
		this.navCtrl.push(HomePage);
	}

}

home.html

<ion-content>
<h2>home page</h2>
<ion-content>

home.ts

import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams, Slides } from 'ionic-angular';
import { ManTabsPage } from'../man-tabs/man-tabs';
//import { ManhomesliderPage } from'../manhomeslider/manhomeslider';

import { SuperTabsController } from 'ionic2-super-tabs';
import { PopoverController } from 'ionic-angular/components/popover/popover-controller';
import { PopoverComponent } from '../../components/popover/popover';

import { WelcomePage } from '../welcome/welcome';
import { Storage } from '@ionic/storage';
import { WomanHomePage } from '../woman-home/woman-home';
/**
 * Generated class for the HomePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
})
export class HomePage {
  rootNavCtrl: NavController;
  @ViewChild(Slides) slides: Slides;
    
  mJumpingjacksRoot = 'MJumpingjacksPage'
  mWallsitRoot = 'MWallsitPage'
  mPushupsRoot = 'MPushupsPage'
  mCrunchesRoot = 'MCrunchesPage'
  mStepupsRoot = 'MStepupsPage'
  mSquatsRoot = 'MSquatsPage'
  mTricepsdipsRoot = 'MTricepsdipsPage'
  mPlankRoot = 'MPlankPage'
  mHighkneesRoot = 'MHighkneesPage'
  mLungesRoot = 'MLungesPage'
  mPushupswithrotationRoot = 'MPushupswithrotationPage'
  mSideplankRoot = 'MSideplankPage'

  constructor(public navCtrl: NavController, public navParams: NavParams, private superTabsCtrl: SuperTabsController, private popoverCtrl: PopoverController, public storage: Storage) {
    this.rootNavCtrl = this.navParams.get('rootNavCtrl');
  } 

  ionViewDidLoad() {
    console.log('ionViewDidLoad HomePage');
    this.storage.get('intro-done-him').then(done => {
    if (!done) {
      this.storage.set('intro-done-him', true);
      this.navCtrl.setRoot(WelcomePage);
    }else{
      this.navCtrl.setRoot(WomanHomePage)
    }
    });
	//this.slides.lockSwipes(true);
  }
  
  /* goToTabPages() {
    this.navCtrl.push(ManTabsPage);
  } 
  
  homesliderPage() {
    this.navCtrl.push(ManhomesliderPage);
  } */
  
  goToTabPages(page) { 
	this.superTabsCtrl.slideTo(page);
	this.slides.slideTo(1, 500);
  }
  
  //public onButtonClick() {
     // this.buttonClicked = !this.buttonClicked;
  //}
  
  gotoslideZero() {
    this.slides.slideTo(0, 500);
  }
  
   presentPopover(myEvent) {
    let popover = this.popoverCtrl.create(PopoverComponent);
    popover.present({
      ev: myEvent
    });
	
	popover.onDidDismiss(popoverData => {
	  console.log('popoverData');
  });
  }
 
}

whomanhome.html

<ion-content>
<h2>home page</h2>
<ion-content>

womanhome.ts

import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams, Slides} from 'ionic-angular';
import { WomanTabsPage } from'../woman-tabs/woman-tabs';

import { SuperTabsController } from 'ionic2-super-tabs';
import { PopoverController } from 'ionic-angular/components/popover/popover-controller';
import { PopoverComponent } from '../../components/popover/popover';

import { WelcomePage } from '../welcome/welcome';
import { Storage } from '@ionic/storage';

/**
 * Generated class for the WomanHomePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-woman-home',
  templateUrl: 'woman-home.html',
})
export class WomanHomePage {
  rootNavCtrl: NavController;
  @ViewChild(Slides) slides: Slides;

  wJumpingjackRoot = 'WJumpingjackPage'
  wWallsitRoot = 'WWallsitPage'
  wPushupsRoot = 'WPushupsPage'
  wCrunchesRoot = 'WCrunchesPage'
  wStepupsRoot = 'WStepupsPage'
  wSquataRoot = 'WSquataPage'
  wTricepsdipsRoot = 'WTricepsdipsPage'
  wPlankRoot = 'WPlankPage'
  wHighkneesRoot = 'WHighkneesPage'
  wLungesRoot = 'WLungesPage'
  wPushupswithrotationRoot = 'WPushupswithrotationPage'
  wSideplankRoot = 'WSideplankPage'

  constructor(public navCtrl: NavController, public navParams: NavParams, private superTabsCtrl: SuperTabsController, private popoverCtrl: PopoverController, public storage: Storage) {
  this.rootNavCtrl = this.navParams.get('rootNavCtrl');
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad WomanHomePage');
    this.storage.get('intro-done-her').then(done => {
    if (!done) {
      this.storage.set('intro-done-her', true);
      this.navCtrl.setRoot(WelcomePage);
    }
    });
    //this.slides.lockSwipes(true);
  }
  
  /* wohometowomantabsPage(){
	  this.navCtrl.push(WomanTabsPage);
  } 
  
   goToTabPages(page) {
	  this.navCtrl.push(WomanTabsPage, { page }, { animate: false });
	} */

  goToTabPages(page) { 
  this.superTabsCtrl.slideTo(page);
  this.slides.slideTo(1, 500);
  }
  
  //public onButtonClick() {
     // this.buttonClicked = !this.buttonClicked;
  //}
  
  gotoslideZero() {
    this.slides.slideTo(0, 500);
  }
  
   presentPopover(myEvent) {
    let popover = this.popoverCtrl.create(PopoverComponent);
    popover.present({
      ev: myEvent
    });
  
  popover.onDidDismiss(popoverData => {
    console.log('popoverData');
  });
  }

}