The Angular PWA Demo implements a custom routing system with extended route metadata for enhanced navigation capabilities.
Extended route interface
The application extends Angular’s standard Route interface to include additional metadata:
app-routing.module.ts:33-38
export interface _Route extends Route
{
id : number;
caption : string;
queryParams : string;
}
This extended interface allows routes to carry presentation metadata (captions) and query parameter identifiers for dynamic content loading.
Route configuration
The application defines 44 routes covering various features:
Core routes
About routes
Algorithm routes
Game routes
File generation
Curriculum routes
Home and navigation
app-routing.module.ts:42-44
{ id: 0, path: 'Home' , component: HomeWebComponent , caption: ' Home' , queryParams : 'PAGE_ANGULAR_DEMO_INDEX' },
{ id: 0, path: 'Index' , component: IndexComponent , caption: ' Index' , queryParams : 'PAGE_HOME_INDEX' },
{ id: 0, path: '' , component: HomeWebComponent , caption: '' , queryParams : '' },
The default route ('') loads the home component, providing a landing page for first-time visitors.Information pages
app-routing.module.ts:45-49
{ id: 0, path: 'SCM' , component: SCMComponent , caption: ' About - SCM' , queryParams : '' },
{ id: 0, path: 'PageUrlList' , component: PageUrlListComponent , caption: ' About - LLM List' , queryParams : 'PAGE_ABOUT_LLM_LIST' },
{ id: 0, path: 'PageUrlList' , component: PageUrlListComponent , caption: ' About - Educational Resources' , queryParams : 'PAGE_ABOUT_EDU_RESC' },
{ id: 0, path: 'TechnicalSpecs' , component: TechnicalSpecsComponent , caption: ' About - Technical Specifications', queryParams : '' },
{ id: 0, path: 'ContactForm' , component: ContactformComponent , caption: ' About - Contact Form' , queryParams : '' },
Notice how PageUrlListComponent is reused with different query parameters to display different content (LLM List vs Educational Resources).
Algorithm demonstrations
app-routing.module.ts:50-53
{ id: 0, path: 'AlgorithmRegEx' , component: AlgorithmRegExComponent , caption: ' Algorithms - Regular Expression' , queryParams : '' },
{ id: 0, path: 'AlgorithmSort' , component: AlgorithmSortComponent , caption: ' Algorithms - Sort' , queryParams : '' },
{ id: 0, path: 'AlgorithmDijkstra' , component: AlgorithmDijkstraComponent , caption: ' Algorithms - Dijkstra - Shortest Path', queryParams : '' },
{ id: 0, path: 'AlgorithmCollision' , component: AlgorithmCollisionComponent , caption: ' Algorithms - Collision - Demo' , queryParams : '' },
Algorithm routes showcase computational demonstrations including pathfinding, sorting, and collision detection.Interactive games
app-routing.module.ts:58-64
{ id: 0, path: 'GamesSudoku' , component: SudokuComponent , caption: ' Games - Sudoku' , queryParams : '' },
{ id: 0, path: 'GamesTicTacToe' , component: GameTictactoeComponent , caption: ' Games - Tic-Tac-Toe' , queryParams : '' },
{ id: 0, path: 'GamesTicTacToeAI' , component: TicTacToeBoardAiComponent , caption: ' Games - Tic-Tac-Toe - A.I.' , queryParams : '' },
{ id: 0, path: 'GamesHanoiAuto' , component: GameHanoiAutoComponent , caption: ' Games - Hanoi 2d' , queryParams : '' },
{ id: 0, path: 'GamesHanoi3d' , component: GameHanoi3dComponent , caption: ' Games - Hanoi 3d' , queryParams : '' },
{ id: 0, path: 'GamesTetris' , component: GameTetrisComponent , caption: ' Games - Tetris' , queryParams : '' },
{ id: 0, path: 'GamesTetrisAI' , component: GameTetrisAIComponent , caption: ' Games - Tetris - A.I.' , queryParams : '' },
Game routes include classic games with both human and AI modes.File export features
app-routing.module.ts:54-57
{ id: 0, path: 'FilesGenerationXLS' , component: FilesGenerationXLSComponent , caption: ' File Generation - XLS' , queryParams : '' },
{ id: 0, path: 'FilesGenerationCSV' , component: FilesGenerationCSVComponent , caption: ' File Generation - CSV' , queryParams : '' },
{ id: 0, path: 'FilesGenerationPDF' , component: FilesGenerationPDFComponent , caption: ' File Generation - PDF' , queryParams : '' },
{ id: 0, path: 'Chart' , component: ChartComponent , caption: ' File Generation - Chart Demo' , queryParams : '' },
These routes demonstrate generating and downloading various file formats.Learning resources
app-routing.module.ts:69-75
{ id: 0, path: 'GridParam' , component: GridParamComponent , caption: ' Curriculum - Artificial Intelligence' , queryParams : 'PAGE_CURRICULUM_AI' },
{ id: 0, path: 'GridParam' , component: GridParamComponent , caption: ' Curriculum - C++' , queryParams : 'PAGE_CURRICULUM_CPP' },
{ id: 0, path: 'CurriculumAngular' , component: CurriculumAngularComponent , caption: ' Curriculum - Angular / Typescript' , queryParams : 'PAGE_CURRICULUM_ANGULAR' },
{ id: 0, path: 'GridParam' , component: GridParamComponent , caption: ' Curriculum - Node.js / Javascript' , queryParams : 'PAGE_CURRICULUM_NODE_JS' },
{ id: 0, path: 'GridParam' , component: GridParamComponent , caption: ' Curriculum - SpringBoot / Java' , queryParams : 'PAGE_CURRICULUM_SPRING_BOOT_JAVA'},
{ id: 0, path: 'GridParam' , component: GridParamComponent , caption: ' Curriculum - Django / Python' , queryParams : 'PAGE_CURRICULUM_DJANGO_PYTHON' },
{ id: 0, path: 'GridParam' , component: GridParamComponent , caption: ' Curriculum - .Net core / C#' , queryParams : 'PAGE_CURRICULUM_NET_CORE' },
Curriculum routes extensively use the GridParamComponent with different query parameters to display technology-specific content.
Route component reuse pattern
The application demonstrates an efficient pattern for component reuse:
// Same component, different content via queryParams
{ path: 'GridParam', component: GridParamComponent,
caption: ' Curriculum - Angular / Typescript',
queryParams : 'PAGE_CURRICULUM_ANGULAR' }
{ path: 'GridParam', component: GridParamComponent,
caption: ' Curriculum - Node.js / Javascript',
queryParams : 'PAGE_CURRICULUM_NODE_JS' }
This pattern reduces code duplication by using a single component to display multiple content variations based on query parameters.
Route ID assignment
The routing module automatically assigns sequential IDs to routes in the constructor:
app-routing.module.ts:93-104
constructor()
{
//
let index : number = 0;
//
routes.forEach(element => {
if (((element.path == '') && (element.caption == ''))==false)
{
element.id = ++index;
}
});
}
Routes with both empty path and caption are excluded from ID assignment, as they represent fallback or utility routes.
Router module configuration
The router is configured with the forRoot method:
app-routing.module.ts:87-90
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
Router configuration options
While not explicitly shown in the configuration, forRoot can accept additional options:
RouterModule.forRoot(routes, {
useHash: false, // Use path-based routing
enableTracing: false, // Debug routing in console
preloadingStrategy: PreloadAllModules, // Lazy loading strategy
scrollPositionRestoration: 'enabled', // Restore scroll on navigation
anchorScrolling: 'enabled', // Enable fragment scrolling
relativeLinkResolution: 'corrected' // Fix relative link resolution
})
Hash location strategy
The application uses hash-based routing:
{ provide: LocationStrategy, useClass: HashLocationStrategy }
Why hash location strategy?
Server compatibility
Works with any web server without URL rewrite configuration
Deployment flexibility
Can be deployed to static hosting without server-side routing setup
Legacy support
Compatible with older browsers and hosting environments
Bookmark friendly
URLs with hash fragments work consistently across all servers
Hash strategy creates URLs like example.com/#/about instead of example.com/about. While less aesthetic, it provides maximum compatibility.
Wildcard route
The last route captures all unmatched URLs:
{ id: 0, path: '**' , component: PageNotFoundComponent , caption: '' , queryParams : '' },
The wildcard route (**) must be the last route in the configuration. It acts as a catch-all for undefined paths.
Navigation patterns
The application supports multiple navigation approaches:
// Navigate to a specific path
this.router.navigate(['/AlgorithmSort']);
Query parameter navigation
// Navigate with query parameters
this.router.navigate(['/GridParam'], {
queryParams: { pageId: 'PAGE_CURRICULUM_ANGULAR' }
});
// Navigate relative to current route
this.router.navigate(['../sibling'], { relativeTo: this.route });
// Navigate with state data
this.router.navigate(['/details'], {
state: { data: selectedItem }
});
Route organization summary
The 44 routes are organized into categories:
| Category | Route Count | Example |
|---|
| Home/Core | 3 | Home, Index, “ |
| About | 5 | SCM, TechnicalSpecs, ContactForm |
| Algorithms | 4 | AlgorithmSort, AlgorithmDijkstra |
| File Generation | 4 | FilesGenerationPDF, Chart |
| Games | 7 | GamesTetris, GamesSudoku |
| Miscellaneous | 3 | Chat, OcrPhotoCapture, FractalDemo |
| Machine Learning | 1 | LinearRegression |
| Curriculum | 7 | CurriculumAngular, various GridParam |
| Demo Languages | 6 | Various GridParam for different tech stacks |
| Utility | 3 | PageUrlList, Landing, ** |
Next steps
Service architecture
Learn about the service layer and dependency injection
PWA features
Understand Progressive Web App capabilities
Architecture overview
Review the complete architecture
Quick start
Get started with development