Skip to main content

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:

  1. An array of routes (Routes[]) is configured in AppRoutingModule.
typescript
const routes: Routes = [ { path: 'home', component: HomeComponent }, { path: 'about', component: AboutComponent } ];
  1. The <router-outlet> directive is used - this is where the matching component appears.
  2. 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 ready
Premium

A concise answer to help you respond confidently on this topic during an interview.