2016-12-13 53 views
2

我ionic2應用程序後,離子2的引導加載主網頁,並開始使用其又使用SQLite的科爾多瓦插件自定義DBService獲取數據,但此時該平臺還沒有準備好,因此sqlitePlugin不可用。平臺準備

如何停止的應用程序來引導,直到平臺已準備就緒(和SQLite數據庫是開放的)?

我發現angular1基於應用程序,其中的Bootstrap被延遲,直到「deviceready」事件被觸發一個solution

任何人都可以提出基於ionic2應用的解決方案?

+0

更新:使用此解決https://github.com/ driftyco/ionic2-app-base/issues/114 –

回答

0
import { Platform } from 'ionic-angular'; 

export class MyApp { 
    constructor(platform: Platform) { 
    platform.ready().then(() => { 
     // Add your method here. 
    }); 
    } 
} 
0

有這種情況在GitHub上的問題:

https://github.com/driftyco/ionic2-app-base/issues/114

調整你的main.ts這樣的:

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(); 
} 
+0

我知道,這個問題是基於這個問題本身創建的。 :) https://forum.ionicframework.com/t/bootstrap-ionic-2-after-platform-ready/73163 –