docs(ngmodule): replace export default
with explicit export (#2206)
Because AoT won't support `export default` for RC6.
This commit is contained in:
parent
82539b69cb
commit
320920e1fd
@ -1,11 +1,10 @@
|
|||||||
import { ModuleWithProviders } from '@angular/core';
|
import { ModuleWithProviders } from '@angular/core';
|
||||||
import { Routes,
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
RouterModule } from '@angular/router';
|
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'contact', pathMatch: 'full'},
|
{ path: '', redirectTo: 'contact', pathMatch: 'full'},
|
||||||
{ path: 'crisis', loadChildren: 'app/crisis/crisis.module' },
|
{ path: 'crisis', loadChildren: 'app/crisis/crisis.module#CrisisModule' },
|
||||||
{ path: 'heroes', loadChildren: 'app/hero/hero.module.3' }
|
{ path: 'heroes', loadChildren: 'app/hero/hero.module.3#HeroModule' }
|
||||||
];
|
];
|
||||||
|
|
||||||
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
// #docregion
|
// #docregion
|
||||||
import { ModuleWithProviders } from '@angular/core';
|
import { ModuleWithProviders } from '@angular/core';
|
||||||
import { Routes,
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
RouterModule } from '@angular/router';
|
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'contact', pathMatch: 'full'},
|
{ path: '', redirectTo: 'contact', pathMatch: 'full'},
|
||||||
// #docregion lazy-routes
|
// #docregion lazy-routes
|
||||||
{ path: 'crisis', loadChildren: 'app/crisis/crisis.module' },
|
{ path: 'crisis', loadChildren: 'app/crisis/crisis.module#CrisisModule' },
|
||||||
{ path: 'heroes', loadChildren: 'app/hero/hero.module' }
|
{ path: 'heroes', loadChildren: 'app/hero/hero.module#HeroModule' }
|
||||||
// #enddocregion lazy-routes
|
// #enddocregion lazy-routes
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -11,6 +11,4 @@ import { routing } from './crisis.routing';
|
|||||||
declarations: [ CrisisDetailComponent, CrisisListComponent ],
|
declarations: [ CrisisDetailComponent, CrisisListComponent ],
|
||||||
providers: [ CrisisService ]
|
providers: [ CrisisService ]
|
||||||
})
|
})
|
||||||
// #docregion export-default
|
export class CrisisModule {}
|
||||||
export default class CrisisModule {}
|
|
||||||
// #enddocregion export-default
|
|
||||||
|
@ -21,5 +21,5 @@ import { HeroService } from './hero.service';
|
|||||||
HighlightDirective
|
HighlightDirective
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export default class HeroModule { }
|
export class HeroModule { }
|
||||||
// #enddocregion class
|
// #enddocregion class
|
||||||
|
@ -18,4 +18,4 @@ import { HeroService } from './hero.service';
|
|||||||
HeroComponent, HeroDetailComponent, HeroListComponent,
|
HeroComponent, HeroDetailComponent, HeroListComponent,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export default class HeroModule { }
|
export class HeroModule { }
|
||||||
|
@ -684,19 +684,9 @@ a#lazy-load
|
|||||||
+makeExample('ngmodule/ts/app/app.routing.ts', 'lazy-routes')(format='.')
|
+makeExample('ngmodule/ts/app/app.routing.ts', 'lazy-routes')(format='.')
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
Note that the lazy loaded module location is a _string_, not a _type_.
|
A lazy loaded module location is a _string_, not a _type_.
|
||||||
|
In this app, the string identifies both the module _file_ and the module _class_,
|
||||||
To reference the _type_ we'd have to use a JavaScript import statement to get the module symbol,
|
the latter separated from the former by a `#`.
|
||||||
which loads the module immediately, defeating our intent to load the module later.
|
|
||||||
|
|
||||||
A string, on the other hand, is just a string. It has no side-effects.
|
|
||||||
:marked
|
|
||||||
The module location strings in this app identify module _files_, not module _classes_.
|
|
||||||
That works because each module class is marked as the default export in its file.
|
|
||||||
+makeExample('ngmodule/ts/app/crisis/crisis.module.ts', 'export-default', '/app/crisis/crisis.module.ts (export default)')(format='.')
|
|
||||||
:marked
|
|
||||||
_Remember to use_ `export default`_ for the lazy loaded module class.
|
|
||||||
Continue to use `export` for all other classes.
|
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
### RouterModule.forRoot
|
### RouterModule.forRoot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user