Advertisement
Beginner Angular, Angular Schematics & Custom Builders

What is an Angular schematic and how does it relate to the ng generate command?

Short answer

A schematic is a template based code generator that the Angular CLI uses to create new files, such as components and services, following consistent naming and structure rules.

Save Angular mock interview
Advertisement
AModel answer
A schematic is a template based code generator that the Angular CLI uses to create new files, such as components and services, following consistent naming and structure rules. Every time you run a command like ng generate component, you are actually running a built in schematic behind the scenes.
ng generate component user-profile
// This runs the built in @schematics/angular component schematic
// which creates the .ts, .html, and .spec.ts files following Angular conventions
Real-world example
A team relies on the built in component schematic every time they add a new feature, ensuring every component in their codebase follows the exact same consistent file naming and folder structure automatically.
Likely follow-ups
  • Can schematics do more than just generate new files, such as modifying existing ones?
  • Where do the built in Angular schematics actually come from?
Related topics