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) { export function postBootstrap(appRef: ComponentRef, prodMode: boolean) {
appRef.injector.get(TapClick); appRef.injector.get(TapClick);
let app: IonicApp = appRef.injector.get(IonicApp); let app: IonicApp = appRef.injector.get(IonicApp);
let platform = appRef.injector.get(Platform); let platform: Platform = appRef.injector.get(Platform);
let zone = appRef.injector.get(NgZone); platform.setZone(appRef.injector.get(NgZone));
platform.prepareReady(zone); platform.prepareReady();
app.setProd(prodMode); app.setProd(prodMode);
} }

View File

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

View File

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