Angular

Routing & Navigation

Router, routes configuration, RouterModule, route parameters, query parameters, route guards, lazy loading, preloading strategies

24 interview questionsยท
Mid-Level
1

What is the Router in Angular?

Answer

The Angular Router enables navigation between different views (components) based on the browser's URL. It handles the mapping between URLs and components, allowing creation of single-page applications with multiple views. The Router watches URL changes and loads the appropriate components into a RouterOutlet.

2

Which module to import to use routing in Angular?

Answer

RouterModule is the Angular module that provides all necessary services and directives for routing (Router service, RouterOutlet, RouterLink, etc.). It is imported from @angular/router and configured with routes via RouterModule.forRoot() for the main module or RouterModule.forChild() for feature modules.

3

How to define routes in Angular?

Answer

Routes are defined in an array of type Routes, where each object specifies a path and the component to display. With standalone components (Angular 14+), use provideRouter(routes) in application configuration. With NgModules, use RouterModule.forRoot(routes) in the main module.

4

How to display route content in the template?

5

How to create a declarative navigation link in the template?

+21 interview questions

Master Angular for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free