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 a new component be generated in Angular using Angular CLI?

  1. ng create component component-name

  2. ng generate component component-name

  3. ng add component component-name

  4. ng make component component-name

The correct answer is: ng generate component component-name

To create a new component in Angular using the Angular CLI, the command involves using the `ng generate` syntax. This is a fundamental feature of the Angular CLI that streamlines the development process by automating repetitive tasks. The `generate` command generates components, directives, services, and more based on the specified parameters. When using `ng generate component component-name`, Angular CLI will set up a new component with the appropriate files, including TypeScript, HTML, and CSS files, and it will also update the module declarations where necessary. This ensures that the new component is ready to be used within the application almost immediately. The other choices do not reflect the correct syntax for generating a new component in Angular. The `create`, `add`, and `make` terms are not part of the Angular CLI command set, which is specifically designed around `generate`, making the correct option clear.