
Now we can update src/app/app.routes.ts to include this new path. We will also add a “default” path that redirects empty requests to the home view, ensuring the user always lands somewhere:
import { Routes } from '@angular/router';
import { App } from './app'; // Matches src/app/app.ts
import { Details } from './details/details'; // Matches src/app/details/details.ts
export const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: App },
{ path: 'details', component: Details },
];
Now if you visit localhost:4200/home, you’ll get the message from the details component: “Details works!”
Next, we’ll use the routerLink directive to move between views without refreshing the page. In src/app/app.html, we create a navigation bar that sits permanently at the top of the page (the “stationary” element), while the router swaps the content below it (the “impermanent” element):
<nav>
<a routerLink="/home">Home</a> |
<a routerLink="/details">Details</a>
</nav>
<hr>
<router-outlet />
And with that, the application has a navigation flow. The user clicks, the URL updates, and the content transforms, all without the jarring flicker of a browser reload.
Parametrized routes
The last thing we’ll look at is handling route parameters, where the route accepts variables in the path. To manage this kind of dynamic data, you define a route with a variable, marked by a colon. Open src/app/app.routes.ts and add a dynamic path:
export const routes: Routes = [
// ... existing routes
{ path: 'details/:id', component: Details },
];
The :id is a placeholder. Whether the URL is /details/42 or /details/108, this router will receive it because it matches the path. Inside the details component, we have access to this parameter (using the ActivatedRoute service or the new withComponentInputBinding). We can use that value to retrieve the data we need (like using it to recover a detail item from a database).
Conclusion
We have seen the core elements of modern Angular: Setting up the environment, building reactive components with signals, organizing logic with services, and tying it all together with interactive routing.
Deploying these pieces together is the basic work in Angular. Once you get comfortable with it, you have an extremely powerful platform at your fingertips. And, when you are ready to go deeper, there is a whole lot more to explore in Angular, including:
- State management: Beyond signals, Angular has support for managing complex, application-wide state.
- Forms: Angular has a robust system for handling user input.
- Signals: We only scratched the surface of signals here. Signals offer a powerful, fine-grained way to manage state changes.
- Build: You can learn more about producing production builds.
- RxJS: Takes reactive programming to the next level.

