From e990594b6d4a43ce40e7ef093d8fbdfd322703ed Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Wed, 9 Nov 2016 18:12:15 +0000 Subject: [PATCH] convert 1-2-hybrid-bootstrap to upgrade/static --- public/docs/_examples/protractor-helpers.ts | 9 +++++-- .../_examples/upgrade-adapter/e2e-spec.ts | 5 ++-- .../ts/app/1-2-hybrid-bootstrap/app.module.ts | 27 +++++++++---------- .../ts/index-1-2-hybrid-bootstrap.html | 1 + .../ts/index-upgrade-static.html | 1 + 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/public/docs/_examples/protractor-helpers.ts b/public/docs/_examples/protractor-helpers.ts index eebf0f57c9..e65835af51 100644 --- a/public/docs/_examples/protractor-helpers.ts +++ b/public/docs/_examples/protractor-helpers.ts @@ -35,6 +35,11 @@ export function waitForNg1AsyncBootstrap() { browser.driver.wait(function() { return element(by.css('.ng-scope')).isPresent(); }, 5000); - // Use this instead when upgrading to protractor > 4.0.10 - // browser.ng12Hybrid = true; +} + +export function setProtractorToHybridMode() { + setProtractorToNg1Mode(); + browser.ng12Hybrid = true; + // remove once waitForNg1AsyncBootstrap() is removed as well + browser.ignoreSynchronization = false; } diff --git a/public/docs/_examples/upgrade-adapter/e2e-spec.ts b/public/docs/_examples/upgrade-adapter/e2e-spec.ts index 16d860bd2f..b7792206cb 100644 --- a/public/docs/_examples/upgrade-adapter/e2e-spec.ts +++ b/public/docs/_examples/upgrade-adapter/e2e-spec.ts @@ -1,7 +1,7 @@ 'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; -import { setProtractorToNg1Mode, waitForNg1AsyncBootstrap } from '../protractor-helpers'; +import { setProtractorToNg1Mode, waitForNg1AsyncBootstrap, setProtractorToHybridMode } from '../protractor-helpers'; describe('Upgrade Tests', function () { @@ -35,9 +35,8 @@ describe('Upgrade Tests', function () { describe('NG1-2 Hybrid Bootstrap', function() { beforeAll(function () { + setProtractorToHybridMode(); browser.get('/index-1-2-hybrid-bootstrap.html'); - setProtractorToNg1Mode(); - waitForNg1AsyncBootstrap(); }); it('bootstraps as expected', function () { diff --git a/public/docs/_examples/upgrade-adapter/ts/app/1-2-hybrid-bootstrap/app.module.ts b/public/docs/_examples/upgrade-adapter/ts/app/1-2-hybrid-bootstrap/app.module.ts index 6ac76407b1..9e54c471e3 100644 --- a/public/docs/_examples/upgrade-adapter/ts/app/1-2-hybrid-bootstrap/app.module.ts +++ b/public/docs/_examples/upgrade-adapter/ts/app/1-2-hybrid-bootstrap/app.module.ts @@ -1,29 +1,28 @@ declare var angular: any; // #docregion ngmodule import { NgModule } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; +import { UpgradeModule } from '@angular/upgrade/static'; @NgModule({ - imports: [ BrowserModule ] + imports: [ + BrowserModule, + UpgradeModule + ] }) -export class AppModule {} +export class AppModule { + ngDoBootstrap() {} +} // #enddocregion ngmodule angular.module('heroApp', []) .controller('MainCtrl', function() { this.message = 'Hello world'; }); - // #docregion bootstrap -import { UpgradeAdapter } from '@angular/upgrade'; - -// #enddocregion bootstrap - -// This blank is expected to trigger the docplaster - -// #docregion bootstrap - -const upgradeAdapter = new UpgradeAdapter(AppModule); - -upgradeAdapter.bootstrap(document.body, ['heroApp'], {strictDi: true}); +platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => { + let upgrade = platformRef.injector.get(UpgradeModule); + upgrade.bootstrap(document.body, ['heroApp'], {strictDi: true}); +}); // #enddocregion bootstrap diff --git a/public/docs/_examples/upgrade-adapter/ts/index-1-2-hybrid-bootstrap.html b/public/docs/_examples/upgrade-adapter/ts/index-1-2-hybrid-bootstrap.html index 593dafe854..a9f67f2096 100644 --- a/public/docs/_examples/upgrade-adapter/ts/index-1-2-hybrid-bootstrap.html +++ b/public/docs/_examples/upgrade-adapter/ts/index-1-2-hybrid-bootstrap.html @@ -16,6 +16,7 @@ + +