update downgrade-static

This commit is contained in:
Filipe Silva 2016-11-10 12:24:20 +00:00
parent 2117d40de3
commit e4bb6ce3cc
3 changed files with 23 additions and 19 deletions

View File

@ -81,9 +81,8 @@ describe('Upgrade Tests', function () {
describe('Downgraded static component', function() { describe('Downgraded static component', function() {
beforeAll(function () { beforeAll(function () {
setProtractorToHybridMode();
browser.get('/index-downgrade-static.html'); browser.get('/index-downgrade-static.html');
setProtractorToNg1Mode();
waitForNg1AsyncBootstrap();
}); });
it('renders', function () { it('renders', function () {

View File

@ -1,30 +1,37 @@
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';
// #docregion downgradecomponent, ngmodule // #docregion downgradecomponent, ngmodule
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() {}
}
// #enddocregion ngmodule // #enddocregion ngmodule
import { UpgradeAdapter } from '@angular/upgrade';
const upgradeAdapter = new UpgradeAdapter(AppModule);
// #docregion downgradecomponent // #docregion downgradecomponent
angular.module('heroApp', []) angular.module('heroApp', [])
.directive('heroDetail', upgradeAdapter.downgradeNg2Component(HeroDetailComponent)); .directive('heroDetail', downgradeComponent({component: HeroDetailComponent}));
// #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

View File

@ -8,6 +8,4 @@ import { Component } from '@angular/core';
<div><label>id: </label>1</div> <div><label>id: </label>1</div>
` `
}) })
export class HeroDetailComponent { export class HeroDetailComponent { }
}