fix(platform): fire cordova platform.ready using zone

Closes #6186
This commit is contained in:
Adam Bradley
2016-04-15 20:35:14 -05:00
parent 2f342d647e
commit ba5624bc04
3 changed files with 13 additions and 7 deletions

View File

@ -69,9 +69,9 @@ export function ionicProviders(args: any = {}) {
export function postBootstrap(appRef: ComponentRef, prodMode: boolean) {
appRef.injector.get(TapClick);
let app: IonicApp = appRef.injector.get(IonicApp);
let platform = appRef.injector.get(Platform);
let zone = appRef.injector.get(NgZone);
platform.prepareReady(zone);
let platform: Platform = appRef.injector.get(Platform);
platform.setZone(appRef.injector.get(NgZone));
platform.prepareReady();
app.setProd(prodMode);
}

View File

@ -48,6 +48,13 @@ export class Platform {
this._readyPromise = new Promise(res => { this._readyResolve = res; } );
}
/**
* @private
*/
setZone(zone: NgZone) {
this._zone = zone;
}
// Methods
// **********************************************
@ -207,11 +214,10 @@ export class Platform {
/**
* @private
*/
prepareReady(zone: NgZone) {
prepareReady() {
// this is the default prepareReady if it's not replaced by the engine
// if there was no custom ready method from the engine
// then use the default DOM ready
this._zone = zone;
ready(this.triggerReady.bind(this));
}

View File

@ -106,7 +106,7 @@ Platform.register({
swipeBackEnabled: isIOSDevice,
swipeBackThreshold: 40,
tapPolyfill: isIOSDevice,
virtualScrollEventAssist: !(window.indexedDB)
virtualScrollEventAssist: !(win.indexedDB)
},
isMatch(p: Platform): boolean {
return p.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']);
@ -172,7 +172,7 @@ Platform.register({
// 1) ionic bootstrapped
windowLoad(function() {
// 2) window onload triggered or completed
doc.addEventListener('deviceready', () => {
doc.addEventListener('deviceready', function() {
// 3) cordova deviceready event triggered
// add cordova listeners to fire platform events