What is routing in Angular?
Routing in Angular is a navigation system within a single-page application (SPA) that allows switching components without reloading the page.
It works like this:
- The user navigates to a URL (for example,
/profile), - Angular analyzes the path and renders the needed component instead of loading a new page from the server.
To make this work:
- An array of routes (
Routes[]) is configured inAppRoutingModule.
typescript
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent }
];- The
<router-outlet>directive is used - this is where the matching component appears. - Navigation happens through
routerLink,navigate(), or manually.
Essentially, routing is a map: URL → component. It makes the application's structure logical, modular, and interactive.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.