Guest User

component

a guest
May 3rd, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import { Platform } from 'ionic-angular';
  3. import { StatusBar } from '@ionic-native/status-bar';
  4. import { SplashScreen } from '@ionic-native/splash-screen';
  5. import { tokenNotExpired } from 'angular2-jwt';
  6. import {Login} from "../pages/login/login";
  7. import {HomePage} from "../pages/home/home";
  8. import {Storage} from "@ionic/storage";
  9. import {Costumize} from "../pages/costumize/costumize";
  10.  
  11. @Component({
  12.   templateUrl: 'app.html'
  13. })
  14. export class MyApp {
  15.   rootPage:any;
  16.  
  17.   constructor(platform: Platform, statusBar: StatusBar,  splashScreen: SplashScreen, storage: Storage) {
  18.     platform.ready().then(() => {
  19.       // Okay, so the platform is ready and our plugins are available.
  20.       // Here you can do any higher level native things you might need.
  21.       statusBar.styleDefault();
  22.       splashScreen.hide();
  23.  
  24.       storage.get('id_token').then(token => {
  25.         if(tokenNotExpired('id_token', token)) {
  26.           storage.get('costumized').then(result => {
  27.             if(result) {
  28.               this.rootPage = HomePage;
  29.             } else {
  30.               this.rootPage = Costumize;
  31.             }
  32.           }).catch(e => {
  33.             this.rootPage = Login
  34.           });
  35.         } else {
  36.           this.rootPage = Login;
  37.         }
  38.       });
  39.     });
  40.  
  41.  
  42.  
  43.   }
  44. }
Add Comment
Please, Sign In to add comment