update 1-to-2-providers
This commit is contained in:
parent
f63649ae45
commit
2bd3a6e0d1
|
@ -145,9 +145,8 @@ describe('Upgrade Tests', function () {
|
|||
describe('Upgrading NG1 Providers', function() {
|
||||
|
||||
beforeAll(function () {
|
||||
setProtractorToHybridMode();
|
||||
browser.get('/index-1-to-2-providers.html');
|
||||
setProtractorToNg1Mode();
|
||||
waitForNg1AsyncBootstrap();
|
||||
});
|
||||
|
||||
it('works', function () {
|
||||
|
|
|
@ -1,21 +1,41 @@
|
|||
declare var angular: any;
|
||||
import { NgModule } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { UpgradeModule, downgradeComponent } from '@angular/upgrade/static';
|
||||
|
||||
import { HeroDetailComponent } from './hero-detail.component';
|
||||
import { HeroesService } from './heroes.service';
|
||||
import { upgradeAdapter } from './upgrade_adapter';
|
||||
|
||||
declare var angular: any;
|
||||
|
||||
// #docregion register
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
UpgradeModule
|
||||
],
|
||||
providers: [{
|
||||
provide: 'heroes',
|
||||
useFactory: (i: any) => i.get('heroes'),
|
||||
deps: ['$injector']
|
||||
}],
|
||||
declarations: [
|
||||
HeroDetailComponent
|
||||
],
|
||||
entryComponents: [
|
||||
HeroDetailComponent
|
||||
]
|
||||
})
|
||||
export class AppModule {
|
||||
ngDoBootstrap() {}
|
||||
}
|
||||
|
||||
angular.module('heroApp', [])
|
||||
.service('heroes', HeroesService)
|
||||
.directive('heroDetail',
|
||||
upgradeAdapter.downgradeNg2Component(HeroDetailComponent));
|
||||
|
||||
upgradeAdapter.upgradeNg1Provider('heroes');
|
||||
.directive('heroDetail', downgradeComponent({component: 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});
|
||||
});
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { HeroDetailComponent } from './hero-detail.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule ],
|
||||
declarations: [ HeroDetailComponent ]
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
angular.module('heroApp', [])
|
||||
.controller('MainCtrl', function() {
|
||||
this.message = 'Hello world';
|
||||
});
|
||||
|
||||
// #docregion
|
||||
import { UpgradeAdapter } from '@angular/upgrade';
|
||||
export const upgradeAdapter = new UpgradeAdapter(AppModule);
|
Loading…
Reference in New Issue