← Angular learning path
Angular · Module 2 of 10

Components and templates

Build UI with components that join a TypeScript class, HTML template and styles.

📖 Key ideas

  1. A component has a class, a template (HTML) and styles.
  2. The @Component decorator sets selector, template and styles.
  3. Standalone components (Angular 15+) need no NgModule.
  4. Generate one with ng generate component card (ng g c card).
  5. Use the selector as a tag: <app-card></app-card>.
💡 Real-life example: A component is a ready-made shop counter: its own look (styles), shelf layout (template) and staff (class).
@ComponentDecorator that defines a component
selectorCustom tag name like app-card
TemplateComponent HTML
StandaloneComponent without an NgModule