What is the Angular CLI create component?

Angular components are the building blocks of the Angular framework.

Generating (or creating) a component in Angular using the CLI is pretty straight-forward.

Usage

To create a component named example, run the following command in the Angular CLI:

ng generate component example

The command performs the following tasks:

  • Creates a directory src/app/example.

  • Inside that directory four files are generated:

    • A CSS file for the component styles
    • An HTML file for the component template
    • A TypeScript file with a component class named ExampleComponent
    • A test file for the ExampleComponent class

The command also adds the ExampleComponent as a declaration in the @NgModule decorator of the src/app/app.module.ts file.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved