diff --git a/public/docs/_examples/upgrade-adapter/e2e-spec.ts b/public/docs/_examples/upgrade-adapter/e2e-spec.ts index 11766a35d3..bfc953952e 100644 --- a/public/docs/_examples/upgrade-adapter/e2e-spec.ts +++ b/public/docs/_examples/upgrade-adapter/e2e-spec.ts @@ -131,9 +131,8 @@ describe('Upgrade Tests', function () { describe('Upgraded component with transclusion', function() { beforeAll(function () { + setProtractorToHybridMode(); browser.get('/index-2-to-1-transclusion.html'); - setProtractorToNg1Mode(); - waitForNg1AsyncBootstrap(); }); it('can be projected into', function () { diff --git a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/app.module.ts b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/app.module.ts index 3484e0d797..3e0641f152 100644 --- a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/app.module.ts +++ b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/app.module.ts @@ -1,15 +1,36 @@ -import { ContainerComponent } from './container.component'; -import { heroDetailComponent } from './hero-detail.component'; -import { upgradeAdapter } from './upgrade_adapter'; - declare var angular: any; +import { NgModule } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { BrowserModule } from '@angular/platform-browser'; +import { UpgradeModule, downgradeComponent } from '@angular/upgrade/static'; + +import { heroDetail, HeroDetailComponent } from './hero-detail.component'; +import { ContainerComponent } from './container.component'; + +// #docregion heroupgrade +@NgModule({ + imports: [ + BrowserModule, + UpgradeModule + ], + declarations: [ + ContainerComponent, + HeroDetailComponent + ], + entryComponents: [ + ContainerComponent + ] +}) +export class AppModule { + ngDoBootstrap() {} +} +// #enddocregion heroupgrade angular.module('heroApp', []) - .directive('myContainer', upgradeAdapter.downgradeNg2Component(ContainerComponent)) - .component('heroDetail', heroDetailComponent); + .component('heroDetail', heroDetail) + .directive('myContainer', downgradeComponent({component: ContainerComponent})); -upgradeAdapter.bootstrap( - document.querySelector('hero-app'), - ['heroApp'], - {strictDi: true} -); +platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => { + let upgrade = platformRef.injector.get(UpgradeModule); + upgrade.bootstrap(document.body, ['heroApp'], {strictDi: true}); +}); diff --git a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/hero-detail.component.ts b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/hero-detail.component.ts index a8f842781d..ada60499f8 100644 --- a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/hero-detail.component.ts +++ b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/hero-detail.component.ts @@ -1,5 +1,5 @@ // #docregion -export const heroDetailComponent = { +export const heroDetail = { bindings: { hero: '=' }, @@ -10,3 +10,18 @@ export const heroDetailComponent = { ` }; + +import { Directive, ElementRef, Injector, Input } from '@angular/core'; +import { UpgradeComponent } from '@angular/upgrade/static'; +import { Hero } from '../hero'; + +@Directive({ + selector: 'hero-detail' +}) +export class HeroDetailComponent extends UpgradeComponent { + @Input() hero: Hero; + + constructor(elementRef: ElementRef, injector: Injector) { + super('heroDetail', elementRef, injector); + } +} diff --git a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/upgrade_adapter.ts b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/upgrade_adapter.ts deleted file mode 100644 index b0f947c8e5..0000000000 --- a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-transclusion/upgrade_adapter.ts +++ /dev/null @@ -1,20 +0,0 @@ -// #docregion -import { UpgradeAdapter } from '@angular/upgrade'; -import { NgModule, forwardRef } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -import { ContainerComponent } from './container.component'; - -export const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule)); -const HeroDetail = upgradeAdapter.upgradeNg1Component('heroDetail'); - -@NgModule({ - imports: [ BrowserModule ], - declarations: [ ContainerComponent, HeroDetail ] -}) -export class AppModule {} - -angular.module('heroApp', []) - .controller('MainCtrl', function() { - this.message = 'Hello world'; - }); diff --git a/public/docs/_examples/upgrade-adapter/ts/app/upgrade-io/hero-detail.component.ts b/public/docs/_examples/upgrade-adapter/ts/app/upgrade-io/hero-detail.component.ts index 07f9ad5b2a..795e753316 100644 --- a/public/docs/_examples/upgrade-adapter/ts/app/upgrade-io/hero-detail.component.ts +++ b/public/docs/_examples/upgrade-adapter/ts/app/upgrade-io/hero-detail.component.ts @@ -16,7 +16,6 @@ export const heroDetail = { } }; - import { Directive, ElementRef, Injector, Input, Output, EventEmitter } from '@angular/core'; import { UpgradeComponent } from '@angular/upgrade/static'; import { Hero } from '../hero';