mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
Merge branch 'dusbuss-add-global-app-injector' into 2.0
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import {Injectable} from 'angular2/core';
|
import {Injectable, Injector} from 'angular2/core';
|
||||||
import {Title} from 'angular2/platform/browser';
|
import {Title} from 'angular2/platform/browser';
|
||||||
|
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
@ -19,6 +19,7 @@ export class IonicApp {
|
|||||||
private _titleSrv: Title = new Title();
|
private _titleSrv: Title = new Title();
|
||||||
private _isProd: boolean = false;
|
private _isProd: boolean = false;
|
||||||
private _rootNav: any = null;
|
private _rootNav: any = null;
|
||||||
|
private _appInjector: Injector;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _config: Config,
|
private _config: Config,
|
||||||
@ -199,4 +200,19 @@ export class IonicApp {
|
|||||||
return this._cmps[id];
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ export function postBootstrap(appRef: ComponentRef, prodMode: boolean) {
|
|||||||
platform.setZone(appRef.injector.get(NgZone));
|
platform.setZone(appRef.injector.get(NgZone));
|
||||||
platform.prepareReady();
|
platform.prepareReady();
|
||||||
app.setProd(prodMode);
|
app.setProd(prodMode);
|
||||||
|
app.setAppInjector(appRef.injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user