mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
fix(angular): backButton event uses ionBackButton
This commit is contained in:
@ -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<Event>();
|
||||
backButton = new EventEmitter<BackButtonDetail>();
|
||||
|
||||
/**
|
||||
* 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<Event>();
|
||||
pause = new EventEmitter<void>();
|
||||
|
||||
/**
|
||||
* 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<Event>();
|
||||
resume = new EventEmitter<void>();
|
||||
|
||||
/**
|
||||
* 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<Event>();
|
||||
resize = new EventEmitter<void>();
|
||||
|
||||
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;
|
||||
|
@ -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<T>(emitter: EventEmitter<T>, el: EventTarget, eventName: string) {
|
||||
el.addEventListener(eventName, (ev) => {
|
||||
emitter.emit(ev);
|
||||
emitter.emit((ev as any).detail as T);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user