mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
fix(angular): platform ready()
This commit is contained in:
@ -1,15 +1,24 @@
|
|||||||
|
|
||||||
import { PlatformConfig } from '@ionic/core';
|
import { PlatformConfig } from '@ionic/core';
|
||||||
|
import { HostListener } from '@angular/core';
|
||||||
|
|
||||||
export class Platform {
|
export class Platform {
|
||||||
|
|
||||||
private _platforms: PlatformConfig[];
|
private _platforms: PlatformConfig[] = [];
|
||||||
private _readyPromise: Promise<any>;
|
private _readyPromise: Promise<any>;
|
||||||
private _readyResolve: any;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._readyPromise = new Promise(res => { this._readyResolve = res; } );
|
let readyResolve: Function;
|
||||||
|
this._readyPromise = new Promise(res => { readyResolve = res; } );
|
||||||
|
if ((window as any)['cordova']) {
|
||||||
|
window.addEventListener('deviceready', () => {
|
||||||
|
readyResolve();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
readyResolve();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean} returns true/false based on platform.
|
* @returns {boolean} returns true/false based on platform.
|
||||||
* @description
|
* @description
|
||||||
@ -102,7 +111,7 @@ export class Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ready(): Promise<string> {
|
ready(): Promise<void> {
|
||||||
return this._readyPromise;
|
return this._readyPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,10 @@ import mdLeaveAnimation from './animations/md.leave';
|
|||||||
})
|
})
|
||||||
export class ActionSheet implements OverlayInterface {
|
export class ActionSheet implements OverlayInterface {
|
||||||
|
|
||||||
presented = false;
|
|
||||||
mode!: Mode;
|
mode!: Mode;
|
||||||
color!: string;
|
color!: string;
|
||||||
|
|
||||||
|
presented = false;
|
||||||
animation?: Animation;
|
animation?: Animation;
|
||||||
|
|
||||||
@Element() el!: HTMLElement;
|
@Element() el!: HTMLElement;
|
||||||
|
@ -89,11 +89,6 @@ describe('parser', () => {
|
|||||||
win = new TestWindow();
|
win = new TestWindow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
export class TestWindow2 {
|
|
||||||
|
|
||||||
}
|
|
||||||
export declare interface TestWindow2 extends Window {}
|
|
||||||
|
|
||||||
|
|
||||||
export function mockRouteElement(win: Window, path: string, component: string) {
|
export function mockRouteElement(win: Window, path: string, component: string) {
|
||||||
const el = win.document.createElement('ion-route');
|
const el = win.document.createElement('ion-route');
|
||||||
|
Reference in New Issue
Block a user