-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(upgrade): Update NgMetadataUpgradeAdapter to support NgModule
BREAKING CHANGE: NgMetadataUpgradeAdapter now accepts an already instantiated @angular/upgrade UpgradeAdapter, which will have been created using an Angular 2 NgModule. **Before:** ```ts import { NgMetadataUpgradeAdapter } from 'ng-metadata/upgrade' import { UpgradeAdapter } from '@angular/upgrade' import { Component } from 'ng-metadata/core' const angular1Module = angular.module('ng1Module', []) @component({ selector: 'app' }) class AppComponent {} const upgradeAdapter = new NgMetadataUpgradeAdapter(UpgradeAdapter) upgradeAdapter.bootstrap(AppComponent, ['ng1Module']) ``` **After:** ```ts import { NgMetadataUpgradeAdapter } from 'ng-metadata/upgrade' import { UpgradeAdapter } from '@angular/upgrade' import { NgModule } from '@angular/core' const angular1Module = angular.module('ng1Module', []) @NgModule({ selector: 'ng2' }) class Ng2Module {} const upgradeAdapter = new NgMetadataUpgradeAdapter( new UpgradeAdapter(Ng2Module) ) upgradeAdapter.boostrap(document.body, ['ng1Module']) ```
- Loading branch information
1 parent
ed1c326
commit 0a81c13
Showing
3 changed files
with
47 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
/** | ||
* `UgradeAdapterRef` controls a hybrid AngularJS v1 / Angular v2 application, | ||
* but we don't have a use for it right now so no point in creating an interface for it... | ||
*/ | ||
export type UgradeAdapterRef = void; | ||
|
||
export interface UpgradeAdapter { | ||
new (): UpgradeAdapterInstance; | ||
} | ||
|
||
export interface UpgradeAdapterInstance { | ||
/** | ||
* Allows Angular v2 Component to be used from AngularJS v1. | ||
*/ | ||
downgradeNg2Component(type: Type): Function; | ||
/** | ||
* Bootstrap a hybrid AngularJS v1 / Angular v2 application. | ||
*/ | ||
bootstrap(element: Element, modules?: any[], config?: angular.IAngularBootstrapConfig): UgradeAdapterRef; | ||
/** | ||
* Adds a provider to the top level environment of a hybrid AngularJS v1 / Angular v2 application. | ||
*/ | ||
addProvider(provider: Type | any[] | any): void; | ||
/** | ||
* Allows Angular v2 service to be accessible from AngularJS v1. | ||
*/ | ||
downgradeNg2Provider(token: any): Function; | ||
/** | ||
* Allows AngularJS v1 service to be accessible from Angular v2. | ||
*/ | ||
upgradeNg1Provider(name: string, options?: { asToken: any; }): void; | ||
} | ||
export { NgMetadataUpgradeAdapter } from './upgrade_adapter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters