2016-12-13 52 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 –