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 do you create a new Angular module using Angular CLI?

  1. ng create module module-name

  2. ng add module module-name

  3. ng generate module module-name

  4. ng module module-name

The correct answer is: ng generate module module-name

Creating a new Angular module using Angular CLI is accomplished with the `ng generate module module-name` command. This command is part of the Angular CLI’s scaffold capabilities, which simplify the development process by automating the creation of various project components. When you use the `ng generate module` command, the CLI performs several tasks: 1. It creates a new folder named after the specified module name within the current directory. 2. Inside this folder, it generates a TypeScript file that serves as the module definition, complete with the necessary imports and decorators to ensure that Angular recognizes it as a module. 3. The command can also include options for routing, if specified, to create a module with routing capabilities. This approach follows best practices in Angular development by promoting the use of modules, which help in organizing an application’s functionality and can enhance performance through lazy loading. The other potential commands do not align with the correct syntax for Angular CLI operations, as they either refer to non-existent commands or misapply the structure for generating modules. Understanding this command is key for Angular developers in structuring their applications effectively.