// app.routes.ts import { Routes } from '@angular/router'; import { HomeComponent } from './home.component'; import { AboutComponent } from './about.component'; import { ContactComponent } from './contact.component'; import { NotFoundComponent } from './not-found.component'; export const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'about', component: AboutComponent }, { path: 'contact', component: ContactComponent }, { path: '**', component: NotFoundComponent }, ]; // main.ts import { bootstrapApplication } from '@angular/platform-browser'; import { provideRouter } from '@angular/router'; import { AppComponent } from './app/app.component'; import { routes } from './app/app.routes'; bootstrapApplication(AppComponent, { providers: [provideRouter(routes)], }); // app.component.ts import { Component } from '@angular/core'; import { RouterOutlet, RouterLink } from '@angular/router'; @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet, RouterLink], template: ` `, }) export class AppComponent {} // home.component.ts (about/contact/not-found follow the same shape) import { Component } from '@angular/core'; @Component({ selector: 'app-home', standalone: true, template: `

Home

`, }) export class HomeComponent {} /* Notes: - provideRouter(routes) in main.ts wires the route config into the app once — the standalone equivalent of the older RouterModule setup. - is where the matched route's component renders; the nav stays put around it on every page. - The '**' wildcard is listed LAST so it only matches URLs nothing above it did. */