diff --git a/angular/src/providers/platform.ts b/angular/src/providers/platform.ts index 2347968b5d..45eb97a4fd 100644 --- a/angular/src/providers/platform.ts +++ b/angular/src/providers/platform.ts @@ -1,5 +1,5 @@ import { EventEmitter, Injectable } from '@angular/core'; -import { Platforms, getPlatforms, isPlatform } from '@ionic/core'; +import { BackButtonDetail, Platforms, getPlatforms, isPlatform } from '@ionic/core'; import { proxyEvent } from '../util/util'; @@ -11,7 +11,7 @@ export class Platform { /** * @hidden */ - backButton = new EventEmitter(); + backButton = new EventEmitter(); /** * The pause event emits when the native platform puts the application @@ -19,26 +19,26 @@ export class Platform { * application. This event would emit when a Cordova app is put into * the background, however, it would not fire on a standard web browser. */ - pause = new EventEmitter(); + pause = new EventEmitter(); /** * The resume event emits when the native platform pulls the application * out from the background. This event would emit when a Cordova app comes * out from the background, however, it would not fire on a standard web browser. */ - resume = new EventEmitter(); + resume = new EventEmitter(); /** * The resize event emits when the browser window has changed dimensions. This * could be from a browser window being physically resized, or from a device * changing orientation. */ - resize = new EventEmitter(); + resize = new EventEmitter(); constructor() { proxyEvent(this.pause, document, 'pause'); proxyEvent(this.resume, document, 'resume'); - proxyEvent(this.backButton, document, 'backbutton'); + proxyEvent(this.backButton, document, 'ionBackButton'); proxyEvent(this.resize, window, 'resize'); let readyResolve: (value: string) => void; diff --git a/angular/src/util/util.ts b/angular/src/util/util.ts index 53a183879b..0362ffa734 100644 --- a/angular/src/util/util.ts +++ b/angular/src/util/util.ts @@ -1,4 +1,4 @@ -import { ElementRef } from '@angular/core'; +import { ElementRef, EventEmitter } from '@angular/core'; export function inputs(instance: any, el: ElementRef, props: string[]) { props.forEach(propName => { @@ -8,9 +8,9 @@ export function inputs(instance: any, el: ElementRef, props: string[]) { }); } -export function proxyEvent(emitter: any, el: EventTarget, eventName: string) { +export function proxyEvent(emitter: EventEmitter, el: EventTarget, eventName: string) { el.addEventListener(eventName, (ev) => { - emitter.emit(ev); + emitter.emit((ev as any).detail as T); }); } diff --git a/core/src/interface.d.ts b/core/src/interface.d.ts index 4f5a4dfbfa..1d2bfd2bfa 100644 --- a/core/src/interface.d.ts +++ b/core/src/interface.d.ts @@ -40,9 +40,11 @@ export type ComponentTags = keyof StencilIntrinsicElements; export type ComponentRef = Function | HTMLElement | string | null; export type ComponentProps = T extends ComponentTags ? StencilIntrinsicElements[T] : {[key: string]: any}; export type CssClassMap = { [className: string]: boolean }; -export type BackButtonEvent = CustomEvent<{ +export interface BackButtonDetail { register(priority: number, handler: () => Promise | void): void; -}> +} + +export type BackButtonEvent = CustomEvent; export interface FrameworkDelegate { attachViewToDom(container: any, component: any, propsOrDataObj?: any, cssClasses?: string[]): Promise;