2017-06-20 81 views
0

我正在使用离子框架构建和应用程序。默认情况下,主目录设置为主页,但我已经开始构建,现在想在此原始主页之前添加登录页面。无论如何,我可以设置新的登录页面作为应用程序的起始页面?谢谢。使用Ionic Framework设置新主页

回答

1

你可以在你的src/app/app.component.ts中做到这一点。 例如

import { Component } from '@angular/core'; 
import { LoginPage } from '...'; 

// other imports 

@Component({ 
  template: `<ion-nav [root]="rootPage"></ion-nav>` 
}) 
export class MyApp { 
  public rootPage: any; 

  constructor(
    platform: Platform 
  ) { 
    platform.ready().then(() => { 
      StatusBar.hide(); 
      Splashscreen.hide(); 
      this.rootPage = LoginPage; // don't forget to import this page 
    }); 
  } 
} 
1

使用rootPage在MyApp的

export class MyApp { 
    rootPage:any = 'YourLoginPage'; 
} 
1

对于登录情况下,你可以使用rootPage财产申报过程中

,像

rootPage:any = Dashboard;//import { Dashboard } from '../pages/dashboard/dashboard' 

或方法中,像

this.rootPage = Dashboard 

后来一旦你登录后全成响应,您可以设置使用应用对象的应用程序的rootPage,像

import { App } from 'ionic/angular' 
import { Dashboard } from '../pages/dashboard/dashboaard' 


//inject in contructor 
constructor(private app:App){} 


//then in method where login success is received 
login(){ 
if(loginValid){ 
    this.app.getRootNav().setRoot(Dashboard);//in this way you will not have back button for new page 
} 
} 

希望它能帮助。 :)