update downgrade-io

This commit is contained in:
Filipe Silva 2016-11-10 12:34:31 +00:00
parent e4bb6ce3cc
commit 71cd604f55
2 changed files with 62 additions and 18 deletions

View File

@ -94,9 +94,8 @@ describe('Upgrade Tests', function () {
describe('Downgraded component with IO', function() { describe('Downgraded component with IO', function() {
beforeAll(function () { beforeAll(function () {
setProtractorToHybridMode();
browser.get('/index-downgrade-io.html'); browser.get('/index-downgrade-io.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
}); });
it('has inputs', function () { it('has inputs', function () {

View File

@ -1,33 +1,78 @@
// 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;
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 { UpgradeModule, downgradeComponent } from '@angular/upgrade/static';
import { MainController } from './main.controller'; import { MainController } from './main.controller';
// #docregion downgradecomponent // #docregion downgradecomponent
import { HeroDetailComponent } from './hero-detail.component'; import { HeroDetailComponent } from './hero-detail.component';
// #enddocregion downgradecomponent // #enddocregion downgradecomponent
@NgModule({ @NgModule({
imports: [ BrowserModule ], imports: [
declarations: [ HeroDetailComponent ] BrowserModule,
UpgradeModule
],
declarations: [
HeroDetailComponent
],
entryComponents: [
HeroDetailComponent
]
}) })
export class AppModule {} export class AppModule {
ngDoBootstrap() {}
import { UpgradeAdapter } from '@angular/upgrade'; }
const upgradeAdapter = new UpgradeAdapter(AppModule);
// #docregion downgradecomponent // #docregion downgradecomponent
angular.module('heroApp', []) angular.module('heroApp', [])
.controller('MainController', MainController) .controller('MainController', MainController)
.directive('heroDetail', upgradeAdapter.downgradeNg2Component(HeroDetailComponent)); .directive('heroDetail', downgradeComponent({
component: HeroDetailComponent,
inputs: ['hero'],
outputs: ['deleted']
}));
// #enddocregion downgradecomponent // #enddocregion downgradecomponent
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} });
);
// #enddocregion bootstrap