← Angular learning pathAngular · Module 2 of 10
Components and templates
Build UI with components that join a TypeScript class, HTML template and styles.
📖 Key ideas
- A component has a class, a template (HTML) and styles.
- The @Component decorator sets selector, template and styles.
- Standalone components (Angular 15+) need no NgModule.
- Generate one with ng generate component card (ng g c card).
- 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