Bootstrap Ionic 2 after platform ready


My ionic2 app loads the main page and starts fetching the data using a custom DBService which in turn uses Cordova SQLite plugin, but at this time the platform is not ready and thus sqlitePlugin is not available.

Can anybody suggest what is the best way to delay bootstrap until the platform is ready (and SQlite db is open)?


I was just experimenting with such an approach. This main.ts seems to work:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';

function bootstrap() {

if (window['cordova']) {
  document.addEventListener('deviceready', () => bootstrap());
} else {

Note that I’m using @ionic/app-scripts version 0.0.47 that requires a single main.ts file.


Raised here: