update 1-to-2-projection

This commit is contained in:
Filipe Silva 2016-11-10 13:57:45 +00:00
parent 71cd604f55
commit 476ccf0001
3 changed files with 26 additions and 51 deletions

View File

@ -117,9 +117,8 @@ describe('Upgrade Tests', function () {
describe('Downgraded component with content projection', function() { describe('Downgraded component with content projection', function() {
beforeAll(function () { beforeAll(function () {
setProtractorToHybridMode();
browser.get('/index-1-to-2-projection.html'); browser.get('/index-1-to-2-projection.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
}); });
it('can be transcluded into', function () { it('can be transcluded into', function () {

View File

@ -1,25 +1,36 @@
declare var angular: any;
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { UpgradeAdapter } from '@angular/upgrade'; import { UpgradeModule, downgradeComponent } from '@angular/upgrade/static';
import { MainController } from './main.controller'; import { MainController } from './main.controller';
import { HeroDetailComponent } from './hero-detail.component'; import { HeroDetailComponent } from './hero-detail.component';
@NgModule({ @NgModule({
imports: [ BrowserModule ], imports: [
declarations: [ HeroDetailComponent ] BrowserModule,
UpgradeModule
],
declarations: [
HeroDetailComponent
],
entryComponents: [
HeroDetailComponent
]
}) })
export class AppModule {} export class AppModule {
ngDoBootstrap() {}
declare var angular: any; }
const upgradeAdapter = new UpgradeAdapter(AppModule);
angular.module('heroApp', []) angular.module('heroApp', [])
.controller('MainController', MainController) .controller('MainController', MainController)
.directive('heroDetail', upgradeAdapter.downgradeNg2Component(HeroDetailComponent)); .directive('heroDetail', downgradeComponent({
component: HeroDetailComponent,
inputs: ['hero']
}));
upgradeAdapter.bootstrap( platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
document.querySelector('hero-app'), let upgrade = platformRef.injector.get(UpgradeModule);
['heroApp'], upgrade.bootstrap(document.body, ['heroApp'], {strictDi: true});
{strictDi: true} });
);

View File

@ -1,38 +1,3 @@
// import { NgModule } from '@angular/core';
// import { BrowserModule } from '@angular/platform-browser';
// import { MainController } from './main.controller';
// #docregion downgradecomponent
// import { HeroDetailComponent } from './hero-detail.component';
// #enddocregion downgradecomponent
// @NgModule({
// imports: [ BrowserModule ],
// declarations: [ HeroDetailComponent ]
// })
// export class AppModule {}
// import { UpgradeAdapter } from '@angular/upgrade';
// const upgradeAdapter = new UpgradeAdapter(AppModule);
// #docregion downgradecomponent
// angular.module('heroApp', [])
// .controller('MainController', MainController)
// .directive('heroDetail', upgradeAdapter.downgradeNg2Component(HeroDetailComponent));
// #enddocregion downgradecomponent
// upgradeAdapter.bootstrap(
// document.querySelector('hero-app'),
// ['heroApp'],
// {strictDi: true}
// );
// // #enddocregion bootstrap
declare var angular: any; declare var angular: any;
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';