update 2-to-1-transclusion
This commit is contained in:
parent
476ccf0001
commit
f63649ae45
|
@ -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 () {
|
||||
|
|
|
@ -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});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// #docregion
|
||||
export const heroDetailComponent = {
|
||||
export const heroDetail = {
|
||||
bindings: {
|
||||
hero: '='
|
||||
},
|
||||
|
@ -10,3 +10,18 @@ export const heroDetailComponent = {
|
|||
</div>
|
||||
`
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
});
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue