Search code examples
angularionic-frameworkionic4

Ionic 4 : Setting root page


In Ionic 4 I couldn't find a suitable way to replace the default root page after the splash screen. Following is the default setup.

this.platform.ready().then(() => {
  this.statusBar.styleDefault();
  this.splashScreen.hide();
});

Solution

  • Found the solution. First create the page you want to make as root page

     ionic generate page pagename
    

    In app.component.ts

     import { Router } from '@angular/router';
    

    Inside the constructor add

     private router : Router
    

    and then initialize

     initializeApp() {
         this.platform.ready().then(() => {
           this.router.navigateByUrl('pagename');
           this.statusBar.styleDefault();
           this.splashScreen.hide();
         });
     }