Last active
July 15, 2017 19:16
-
-
Save DaveMBush/49d3511d11b1f16a976f9e9796511381 to your computer and use it in GitHub Desktop.
Angular Routing
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
export const routes: Routes = []; | |
@NgModule({}) | |
export class AppRoutesModule {} |
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
import {RouterModule, Routes} from ‘@anguler/router’; | |
export const routes: Routes = []; | |
@NgModule({}) | |
export class AppRoutesModule {} |
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
export const routes: Routes = [{ | |
path: ‘page1’, | |
children: [ | |
{ | |
path: ‘’, | |
pathMatch: ‘full’, | |
component: ‘Page1Component’ }, | |
{ | |
path: ‘subpage’, | |
component: Page1SubpageComponent | |
}]}, { | |
path: ‘page2’, | |
component: Page2Component | |
}] |
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
import {Page1Component} from './routes/page1/page1.component'; | |
import {Page2Component} from './routes/page2/page2.component'; | |
import {Page1SubpageComponent} | |
from './routes/page1.subpage/page1-subpage.component'; |
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: [RouterModule.forRoot(routes)], | |
exports: [RouterModule] | |
}) | |
export class AppRoutesModule { | |
} |
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
{ | |
path: ‘’, | |
redirectTo: ‘page1’, | |
pathMatch: ‘full’ | |
}, |
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
export const routes: Routes = [{ | |
path: '', | |
redirectTo: 'page1', | |
pathMatch: 'full' | |
}, { | |
path: 'page1', | |
loadChildren: './routes/page1/page1.module#Page1Module' | |
}, { | |
path: 'page2', | |
loadChildren: './routes/page2/page2.module#Page2Module' | |
}] |
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
<router-outlet></router-outlet> |
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
import {AppRoutesModule} from ‘./app-routes.module’; | |
@NgModule({ | |
…, | |
imports: [ | |
…, | |
AppRoutesModule | |
], | |
… | |
} |
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
RouterModule.forChild([{ | |
path: '', | |
pathMatch: 'full', | |
component: Page1SubpageComponent | |
}]), |
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
RouterModule.forChild([{ | |
path: '', | |
pathMatch: 'full', | |
component: Page1Component | |
}, { | |
path: 'subpage', | |
loadChildren: ‘../page1.subpage/page1-subpage.module#Page1SubpageModule’ | |
}]), |
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
RouterModule.forChild([{ | |
path: '', | |
pathMatch: 'full', | |
component: Page2Component | |
}]), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment