Prepare for Angular Interviews with real-life questions. Utilize quizzes and examples to deepen understanding and enhance your skills. Gear up to ace your interview!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


How can you enable routing in a new Angular project during its creation?

  1. By using the --routing flag with ng generate

  2. By using the --routing flag when creating the project

  3. By updating the angular.json file manually

  4. By creating a router module after project creation

The correct answer is: By using the --routing flag when creating the project

Enabling routing in a new Angular project is achieved by utilizing the --routing flag during the project creation process. This flag informs the Angular CLI to set up the necessary files and configurations to support routing right from the beginning. When you create a new project with this option, Angular automatically generates a routing module that can be used to define the routes for your application. This setup saves time and ensures that the routing configuration adheres to Angular's best practices. This approach stands out because it integrates routing seamlessly into the project architecture from the start, allowing developers to focus on building features rather than spending time setting up routing afterward. The automatically generated routing module can be easily modified to define various application routes, manage lazy loading, and handle parameters, making it a foundational aspect for larger applications. Other methods of enabling routing, such as updating the angular.json file manually or creating a router module after the project's initial setup, require additional steps and do not provide the same level of initial convenience and integration that using the --routing flag offers during project creation.