diff --git a/packages/angular/src/index.ts b/packages/angular/src/index.ts index 8d5e84d9d0..819dae6985 100644 --- a/packages/angular/src/index.ts +++ b/packages/angular/src/index.ts @@ -29,3 +29,40 @@ export { PopoverController, PopoverProxy } from './providers/popover-controller' export { ToastController, ToastProxy } from './providers/toast-controller'; export * from './types/interfaces'; + + +import { IonicWindow } from './types/interfaces'; + +const win = (window as IonicWindow); +const Ionic = win.Ionic; + +if (!Ionic) { + throw new Error(`ionic.js script missing from index.html`); + +} else { + + Ionic.ael = function ngAddEventListener(elm, eventName, cb, opts) { + if (elm.__zone_symbol__addEventListener) { + elm.__zone_symbol__addEventListener(eventName, cb, opts); + } else { + elm.addEventListener(eventName, cb, opts); + } + }; + + Ionic.rel = function ngRemoveEventListener(elm, eventName, cb, opts) { + if (elm.__zone_symbol__removeEventListener) { + elm.__zone_symbol__removeEventListener(eventName, cb, opts); + } else { + elm.removeEventListener(eventName, cb, opts); + } + }; + + Ionic.raf = function ngRequestAnimationFrame(cb: any) { + if (win.__zone_symbol__requestAnimationFrame) { + win.__zone_symbol__requestAnimationFrame(cb); + } else { + win.requestAnimationFrame(cb); + } + }; + +} diff --git a/packages/angular/src/types/interfaces.ts b/packages/angular/src/types/interfaces.ts index 6a964f2a22..608affa7f0 100644 --- a/packages/angular/src/types/interfaces.ts +++ b/packages/angular/src/types/interfaces.ts @@ -24,13 +24,12 @@ export interface AngularEscapeHatch extends EscapeHatch { export interface IonicGlobal { config: any; - Events: { - subscribe: (topic: string, ...handlers: Function[]) => void; - unsubscribe: (topic: string, handler: Function) => void; - publish: (topic: string, ...args: any[]) => any[]; - }; + ael: (elm: any, eventName: string, cb: Function, opts: any) => void; + raf: Function; + rel: (elm: any, eventName: string, cb: Function, opts: any) => void; } export interface IonicWindow extends Window { Ionic: IonicGlobal; + __zone_symbol__requestAnimationFrame: Function; }