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() {
|
describe('Upgrading NG1 Providers', function() {
|
||||||
|
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
|
setProtractorToHybridMode();
|
||||||
browser.get('/index-1-to-2-providers.html');
|
browser.get('/index-1-to-2-providers.html');
|
||||||
setProtractorToNg1Mode();
|
|
||||||
waitForNg1AsyncBootstrap();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works', function () {
|
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 { HeroDetailComponent } from './hero-detail.component';
|
||||||
import { HeroesService } from './heroes.service';
|
import { HeroesService } from './heroes.service';
|
||||||
import { upgradeAdapter } from './upgrade_adapter';
|
|
||||||
|
|
||||||
declare var angular: any;
|
|
||||||
|
|
||||||
// #docregion register
|
// #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', [])
|
angular.module('heroApp', [])
|
||||||
.service('heroes', HeroesService)
|
.service('heroes', HeroesService)
|
||||||
.directive('heroDetail',
|
.directive('heroDetail', downgradeComponent({component: HeroDetailComponent}));
|
||||||
upgradeAdapter.downgradeNg2Component(HeroDetailComponent));
|
|
||||||
|
|
||||||
upgradeAdapter.upgradeNg1Provider('heroes');
|
|
||||||
|
|
||||||
// #enddocregion register
|
// #enddocregion register
|
||||||
|
|
||||||
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}
|
});
|
||||||
);
|
|
||||||
|
|
|
@ -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