Skip to content

Instantly share code, notes, and snippets.

@Ademking
Last active July 20, 2018 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ademking/54aaf0836039e98f1ee937b51015db46 to your computer and use it in GitHub Desktop.
Save Ademking/54aaf0836039e98f1ee937b51015db46 to your computer and use it in GitHub Desktop.
πŸ’™ Ionic 3 : How to make welcome page with Storage

app.component.ts

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { Storage } from '@ionic/storage';
import { LoadingController } from 'ionic-angular';

import { TabsPage } from '../pages/tabs/tabs';
import { WelcomeSlidePage } from '../pages/welcome-slide/welcome-slide';


@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = TabsPage;
  loader: any;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, public loadingCtrl: LoadingController, public storage: Storage) {

          this.presentLoading();

          platform.ready().then(() => {

            this.storage.get('introShown').then((result) => {

              if(result){
                this.rootPage = TabsPage;
              } else {
                this.rootPage = WelcomeSlidePage;
                this.storage.set('introShown', true);
              }

              this.loader.dismiss();

            });

            statusBar.styleDefault();
            splashScreen.hide();


          });

  }

  presentLoading() {

    this.loader = this.loadingCtrl.create({
      content: "Loading..."
    });

    this.loader.present();

  }



}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment