Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 5c0ae56

Browse files
committed
update upgrade-static
1 parent 455f2f6 commit 5c0ae56

File tree

5 files changed

+47
-38
lines changed

5 files changed

+47
-38
lines changed

public/docs/_examples/upgrade-adapter/e2e-spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ describe('Upgrade Tests', function () {
4848
describe('Upgraded static component', function() {
4949

5050
beforeAll(function () {
51+
setProtractorToHybridMode();
5152
browser.get('/index-upgrade-static.html');
52-
setProtractorToNg1Mode();
53-
waitForNg1AsyncBootstrap();
5453
});
5554

5655
it('renders', function () {

public/docs/_examples/upgrade-adapter/ts/app/upgrade-static/app.module.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
1-
import { heroDetail } from './hero-detail.component';
1+
declare var angular: any;
2+
import { NgModule } from '@angular/core';
3+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
4+
import { BrowserModule } from '@angular/platform-browser';
5+
import { UpgradeModule, downgradeComponent } from '@angular/upgrade/static';
6+
7+
import { heroDetail, HeroDetailComponent } from './hero-detail.component';
28
import { ContainerComponent } from './container.component';
3-
import { upgradeAdapter } from './upgrade_adapter';
49

5-
6-
declare var angular: any;
10+
// #docregion heroupgrade
11+
@NgModule({
12+
imports: [
13+
BrowserModule,
14+
UpgradeModule
15+
],
16+
declarations: [
17+
ContainerComponent,
18+
HeroDetailComponent
19+
],
20+
entryComponents: [
21+
ContainerComponent
22+
]
23+
})
24+
export class AppModule {
25+
ngDoBootstrap() {}
26+
}
27+
// #enddocregion heroupgrade
728

829
angular.module('heroApp', [])
930
.component('heroDetail', heroDetail)
10-
.directive('myContainer', upgradeAdapter.downgradeNg2Component(ContainerComponent));
31+
.directive('myContainer', downgradeComponent({component: ContainerComponent}));
32+
33+
platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
34+
let upgrade = platformRef.injector.get(UpgradeModule);
35+
upgrade.bootstrap(document.body, ['heroApp'], {strictDi: true});
36+
});
1137

12-
upgradeAdapter.bootstrap(
13-
document.querySelector('hero-app'),
14-
['heroApp'],
15-
{strictDi: true}
16-
);

public/docs/_examples/upgrade-adapter/ts/app/upgrade-static/container.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ import { Component } from '@angular/core';
88
<hero-detail></hero-detail>
99
`
1010
})
11-
export class ContainerComponent {
12-
13-
}
11+
export class ContainerComponent { }

public/docs/_examples/upgrade-adapter/ts/app/upgrade-static/hero-detail.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@ export const heroDetail = {
77
controller: function() {
88
}
99
};
10+
11+
// #docregion heroupgrade
12+
import { Directive, ElementRef, Injector } from '@angular/core';
13+
import { UpgradeComponent } from '@angular/upgrade/static';
14+
15+
@Directive({
16+
selector: 'hero-detail'
17+
})
18+
export class HeroDetailComponent extends UpgradeComponent {
19+
constructor(elementRef: ElementRef, injector: Injector) {
20+
super('heroDetail', elementRef, injector);
21+
}
22+
}
23+
// #enddocregion heroupgrade

public/docs/_examples/upgrade-adapter/ts/app/upgrade-static/upgrade_adapter.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)