diff --git a/packages/upgrade/src/common/angular1.ts b/packages/upgrade/src/common/angular1.ts index 329573ddb9..6638cc898f 100644 --- a/packages/upgrade/src/common/angular1.ts +++ b/packages/upgrade/src/common/angular1.ts @@ -243,22 +243,36 @@ try { } /** - * Resets the AngularJS library. + * @deprecated Use {@link setAngularJSGlobal} instead. + */ +export function setAngularLib(ng: any): void { + setAngularJSGlobal(ng); +} + +/** + * @deprecated Use {@link getAngularJSGlobal} instead. + */ +export function getAngularLib(): any { + return getAngularJSGlobal(); +} + +/** + * Resets the AngularJS global. * - * Used when angularjs is loaded lazily, and not available on `window`. + * Used when AngularJS is loaded lazily, and not available on `window`. * * @stable */ -export function setAngularLib(ng: any): void { +export function setAngularJSGlobal(ng: any): void { angular = ng; } /** - * Returns the current version of the AngularJS library. + * Returns the current AngularJS global. * * @stable */ -export function getAngularLib(): any { +export function getAngularJSGlobal(): any { return angular; } diff --git a/packages/upgrade/static/public_api.ts b/packages/upgrade/static/public_api.ts index 536890d321..c881be7a53 100644 --- a/packages/upgrade/static/public_api.ts +++ b/packages/upgrade/static/public_api.ts @@ -12,7 +12,7 @@ * Entry point for all public APIs of this package. allowing * Angular 1 and Angular 2+ to run side by side in the same application. */ -export {getAngularLib, setAngularLib} from './src/common/angular1'; +export {getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib} from './src/common/angular1'; export {downgradeComponent} from './src/common/downgrade_component'; export {downgradeInjectable} from './src/common/downgrade_injectable'; export {VERSION} from './src/common/version'; @@ -20,4 +20,5 @@ export {downgradeModule} from './src/static/downgrade_module'; export {UpgradeComponent} from './src/static/upgrade_component'; export {UpgradeModule} from './src/static/upgrade_module'; + // This file only re-exports content of the `src` folder. Keep it that way. diff --git a/packages/upgrade/test/static/integration/injection_spec.ts b/packages/upgrade/test/static/integration/injection_spec.ts index 8ee142c2f4..fa7ce8e4e1 100644 --- a/packages/upgrade/test/static/integration/injection_spec.ts +++ b/packages/upgrade/test/static/integration/injection_spec.ts @@ -12,7 +12,7 @@ import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import * as angular from '@angular/upgrade/src/common/angular1'; import {$INJECTOR, INJECTOR_KEY} from '@angular/upgrade/src/common/constants'; -import {UpgradeModule, downgradeInjectable, getAngularLib, setAngularLib} from '@angular/upgrade/static'; +import {UpgradeModule, downgradeInjectable, getAngularJSGlobal, setAngularJSGlobal} from '@angular/upgrade/static'; import {bootstrap, html} from '../test_helpers'; @@ -103,9 +103,9 @@ export function main() { it('should allow resetting angular at runtime', async(() => { let wrappedBootstrapepedCalled = false; - const n: any = getAngularLib(); + const n: any = getAngularJSGlobal(); - setAngularLib({ + setAngularJSGlobal({ bootstrap: (...args: any[]) => { wrappedBootstrapepedCalled = true; n.bootstrap(...args); diff --git a/tools/public_api_guard/upgrade/static.d.ts b/tools/public_api_guard/upgrade/static.d.ts index 8af9735a03..3ff9b4b9a0 100644 --- a/tools/public_api_guard/upgrade/static.d.ts +++ b/tools/public_api_guard/upgrade/static.d.ts @@ -14,9 +14,15 @@ export declare function downgradeInjectable(token: any): Function; export declare function downgradeModule(moduleFactoryOrBootstrapFn: NgModuleFactory | ((extraProviders: StaticProvider[]) => Promise>)): string; /** @stable */ +export declare function getAngularJSGlobal(): any; + +/** @deprecated */ export declare function getAngularLib(): any; /** @stable */ +export declare function setAngularJSGlobal(ng: any): void; + +/** @deprecated */ export declare function setAngularLib(ng: any): void; /** @experimental */