Reputation: 1095
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.
How do I stop application to bootstrap until the platform is ready (and SQlite db is open)?
I found a solution for angular1 based apps where bootstraping is delayed until 'deviceready' event is fired.
Can anybody suggest a solution for ionic2 based apps?
Upvotes: 2
Views: 1369
Reputation: 27
There's an issue for this case on GitHub:
https://github.com/driftyco/ionic2-app-base/issues/114
Adjust your main.ts
like this:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
function bootstrap() {
platformBrowserDynamic().bootstrapModule(AppModule);
}
if (window['cordova']) {
document.addEventListener('deviceready', () => bootstrap());
} else {
bootstrap();
}
Upvotes: 0
Reputation: 6094
import { Platform } from 'ionic-angular';
export class MyApp {
constructor(platform: Platform ) {
platform.ready().then(() => {
// Add your method here.
});
}
}
Upvotes: 0