From 03d877dcee72badf3723d7db1d1e5d2a3738b702 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Thu, 10 Nov 2016 14:33:58 +0000 Subject: [PATCH] update 2-to-1-providers --- .../_examples/upgrade-adapter/e2e-spec.ts | 3 +- .../ts/app/2-to-1-providers/app.module.ts | 31 +++++++++++++------ .../app/2-to-1-providers/upgrade_adapter.ts | 19 ------------ 3 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/upgrade_adapter.ts diff --git a/public/docs/_examples/upgrade-adapter/e2e-spec.ts b/public/docs/_examples/upgrade-adapter/e2e-spec.ts index 61dad44e0b..540ebcdecc 100644 --- a/public/docs/_examples/upgrade-adapter/e2e-spec.ts +++ b/public/docs/_examples/upgrade-adapter/e2e-spec.ts @@ -159,9 +159,8 @@ describe('Upgrade Tests', function () { describe('Downgrading NG2 Providers', function() { beforeAll(function () { + setProtractorToHybridMode(); browser.get('/index-2-to-1-providers.html'); - setProtractorToNg1Mode(); - waitForNg1AsyncBootstrap(); }); it('works', function () { diff --git a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/app.module.ts b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/app.module.ts index 16b77819c5..39b8488653 100644 --- a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/app.module.ts +++ b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/app.module.ts @@ -1,17 +1,30 @@ +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, downgradeInjectable } from '@angular/upgrade/static'; + import { heroDetailComponent } from './hero-detail.component'; import { Heroes } from './heroes'; -import { upgradeAdapter } from './upgrade_adapter'; - -declare var angular: any; +@NgModule({ + imports: [ + BrowserModule, + UpgradeModule + ], + providers: [ Heroes ] +}) +export class AppModule { + ngDoBootstrap() {} +} // #docregion register angular.module('heroApp', []) - .factory('heroes', upgradeAdapter.downgradeNg2Provider(Heroes)) + .factory('heroes', downgradeInjectable(Heroes)) .component('heroDetail', heroDetailComponent); // #enddocregion register -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}); +}); diff --git a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/upgrade_adapter.ts b/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/upgrade_adapter.ts deleted file mode 100644 index d99d587f0f..0000000000 --- a/public/docs/_examples/upgrade-adapter/ts/app/2-to-1-providers/upgrade_adapter.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -// #docregion ngmodule -import { Heroes } from './heroes'; - -@NgModule({ - imports: [ BrowserModule ], - providers: [ Heroes ] -}) -export class AppModule {} -// #enddocregion ngmodule -angular.module('heroApp', []) - .controller('MainCtrl', function() { - this.message = 'Hello world'; - }); - -// #docregion -import { UpgradeAdapter } from '@angular/upgrade'; -export const upgradeAdapter = new UpgradeAdapter(AppModule);