update 2-to-1-providers

This commit is contained in:
Filipe Silva 2016-11-10 14:33:58 +00:00
parent 2bd3a6e0d1
commit 03d877dcee
3 changed files with 23 additions and 30 deletions

View File

@ -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 () {

View File

@ -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});
});

View File

@ -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);