2017-09-25 7 views
0

앱의 첫 번째 타이머와 다른 사용자의 로그인 페이지에 대한 자습서 페이지를 설정하려고합니다. 사용자가 튜토리얼 페이지를 통과 한 경우 localstorage에서 키 값을 설정합니다. 코드 위Ionic3에서 조건부로 rootPage를 설정하는 방법

export class MyApp { 
rootPage: any = LoginPage; 

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 
    platform.ready().then(() => { 
     statusBar.styleDefault(); 
     if(!localStorage.getItem('tutorial')) { 
      this.rootPage = TutorialPage; 
     } 
     splashScreen.hide(); 
    }); 
    } 
} 

는 잘 작동하지만, 튜토리얼 페이지를 설정하고 로그인 페이지 다음 튜토리얼 페이지가 다가오고 처음 보는 지연이있다. 나는 내가 이것을 올바른 방법으로하고 있는지 또는 뭔가를 놓치고 있는지 알고 싶다.

+1

'rootPage : any = LoginPage;를 제거하고'rootPage : any; '만 사용하고'else'블록을'constructor'에 넣습니다. – hrdkisback

+0

답장을 보내 주셔서 감사합니다. @hrdkisback 그것은 일했다! – Shubham

답변

0

내가 당신을 위해 작업을 희망 코드

export class MyApp { 
rootPage: any; 

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { 
    platform.ready().then(() => { 
     statusBar.styleDefault(); 
     if(!localStorage.getItem('tutorial')) { 
      this.rootPage = TutorialPage; // user can user this.nav.setRoot(TutorialPage); 
     }else{ 
      this.rootPage = LoginPage; // user can user this.nav.setRoot(LoginPage); 
     } 
     splashScreen.hide(); 
    }); 
    } 
} 

다음 사용하시기 바랍니다.