What is Angular routing?
Why Interviewers Ask This
This is a classic screening question for Angular roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
Angular Router enables navigation between views (components) in a SPA without full page reloads — updating the URL to reflect the current view while keeping the app state. Setup: import RouterModule.forRoot(routes) in AppModule with a routes array: const routes: Routes = [ { path: "", component: HomeComponent }, { path: "users", component: UsersComponent }, { path: "users/:id", component: UserDetailComponent }, { path: "admin", loadChildren: () => import("./admin/admin.module").then(m => m.AdminModule) }, { path: "**", component: NotFoundComponent } ];. Router outlet: <router-outlet></router-outlet> in the template — placeholder where routed components are rendered. Navigation: in templates: <a routerLink="/users/123" routerLinkActive="active">; programmatically: this.router.navigate(["/users", userId]); with query params: this.router.navigate(["/search"], { queryParams: { q: "angular" } }). Route parameters: read via ActivatedRoute: this.route.params.subscribe(params => { this.userId = params["id"]; }) or snapshot: this.route.snapshot.params["id"]. Child routes: nested routes within a parent component. Lazy loading: loadChildren defers loading the feature module until the route is first visited — improves initial load time. Guards: CanActivate, CanDeactivate, CanLoad protect routes.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Angular codebase.