Last active
August 22, 2016 06:48
-
-
Save brandonroberts/f17493b416092055615b8fc0830c127a to your computer and use it in GitHub Desktop.
Route Modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
imports: [ | |
routing, | |
MainModule | |
] | |
}) | |
export class MainModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes: Routes = [ | |
{path: 'home', component: Home}, | |
{path: 'settings', component: Settings}, | |
{path: '', redirectTo: '/home', pathMatch: 'full'} | |
] | |
export const routing = RouterModule.forRoot(routes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The router will flatten all the route arrays together | |
const routes: Routes = [ | |
{path: 'home', component: Home}, | |
{path: 'settings', component: Settings}, | |
{path: '', redirectTo: '/home', pathMatch: 'full'}, | |
{ | |
path: 'apis’, | |
component: Main, | |
children: [ | |
{path: ':apiCall', component: ApiDocList}, | |
{path: ':apiCall/detail/:operation', component: ApiDocDetail} | |
] | |
} | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
imports: [ | |
mainRouting | |
] | |
}) | |
export class MainModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mainRoutes: Routes = [ | |
{ | |
path: 'apis’, | |
component: Main, | |
children: [ | |
{path: ':apiCall', component: ApiDocList}, | |
{path: ':apiCall/detail/:operation', component: ApiDocDetail} | |
] | |
} | |
] | |
export const mainRouting = RouterModule.forChild(mainRoutes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
flattened-routes-example.ts
has some minor issues, probably some copy-pasting errors. It has one []](https://gist.github.com/brandonroberts/f17493b416092055615b8fc0830c127a#file-flattened-routes-example-ts-L16) too much at the end.