update upgrade-static
This commit is contained in:
parent
455f2f6896
commit
f958661afe
|
@ -48,9 +48,8 @@ describe('Upgrade Tests', function () {
|
|||
describe('Upgraded static component', function() {
|
||||
|
||||
beforeAll(function () {
|
||||
setProtractorToHybridMode();
|
||||
browser.get('/index-upgrade-static.html');
|
||||
setProtractorToNg1Mode();
|
||||
waitForNg1AsyncBootstrap();
|
||||
});
|
||||
|
||||
it('renders', function () {
|
||||
|
|
|
@ -1,16 +1,36 @@
|
|||
import { heroDetail } from './hero-detail.component';
|
||||
import { ContainerComponent } from './container.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', [])
|
||||
.component('heroDetail', heroDetail)
|
||||
.directive('myContainer', upgradeAdapter.downgradeNg2Component(ContainerComponent));
|
||||
.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});
|
||||
});
|
||||
|
|
|
@ -8,6 +8,4 @@ import { Component } from '@angular/core';
|
|||
<hero-detail></hero-detail>
|
||||
`
|
||||
})
|
||||
export class ContainerComponent {
|
||||
|
||||
}
|
||||
export class ContainerComponent { }
|
||||
|
|
|
@ -7,3 +7,17 @@ export const heroDetail = {
|
|||
controller: function() {
|
||||
}
|
||||
};
|
||||
|
||||
// #docregion heroupgrade
|
||||
import { Directive, ElementRef, Injector } from '@angular/core';
|
||||
import { UpgradeComponent } from '@angular/upgrade/static';
|
||||
|
||||
@Directive({
|
||||
selector: 'hero-detail'
|
||||
})
|
||||
export class HeroDetailComponent extends UpgradeComponent {
|
||||
constructor(elementRef: ElementRef, injector: Injector) {
|
||||
super('heroDetail', elementRef, injector);
|
||||
}
|
||||
}
|
||||
// #enddocregion heroupgrade
|
||||
|
|
|
@ -1,23 +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));
|
||||
|
||||
// #docregion heroupgrade
|
||||
const HeroDetail = upgradeAdapter.upgradeNg1Component('heroDetail');
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule ],
|
||||
declarations: [ ContainerComponent, HeroDetail ]
|
||||
})
|
||||
export class AppModule {}
|
||||
// #enddocregion heroupgrade
|
||||
|
||||
angular.module('heroApp', [])
|
||||
.controller('MainCtrl', function() {
|
||||
this.message = 'Hello world';
|
||||
});
|
Loading…
Reference in New Issue