diff --git a/ionic/components/app/app.ts b/ionic/components/app/app.ts index 530d911247..011c8fc68c 100644 --- a/ionic/components/app/app.ts +++ b/ionic/components/app/app.ts @@ -1,4 +1,4 @@ -import {Injectable, NgZone} from 'angular2/core'; +import {Injectable, Injector, NgZone} from 'angular2/core'; import {Title} from 'angular2/platform/browser'; import {Config} from '../../config/config'; @@ -18,6 +18,7 @@ export class IonicApp { private _title: string = ''; private _titleSrv: Title = new Title(); private _isProd: boolean = false; + private _appInjector: Injector; constructor( private _config: Config, @@ -155,4 +156,19 @@ export class IonicApp { return this._cmps[id]; } + /** + * Set the global app injector that contains references to all of the instantiated providers + * @param injector + */ + setAppInjector(injector: Injector) { + this._appInjector = injector; + } + + /** + * Get an instance of the global app injector that contains references to all of the instantiated providers + * @returns {Injector} + */ + getAppInjector(): Injector { + return this._appInjector; + } } diff --git a/ionic/decorators/app.ts b/ionic/decorators/app.ts index 8f885d8e86..1b87843ec5 100644 --- a/ionic/decorators/app.ts +++ b/ionic/decorators/app.ts @@ -96,6 +96,7 @@ export function App(args: AppMetadata={}) { bootstrap(cls, providers).then(appRef => { appRef.injector.get(TapClick); let app: IonicApp = appRef.injector.get(IonicApp); + app.setAppInjector(appRef.injector); app.setProd(args.prodMode); });