What Is a Component?
A component is a small, reusable piece of the screen: a header, a product card, a login form. It has three parts: TypeScript (data and behavior), an HTML template (what is shown) and CSS (how it looks).
Generate a Component
The CLI creates four files in src/app/greeting/ (names depend on your CLI version):
Use It in Another Component
Two steps: import the class and use the selector in the template.
Hello, Ana! Hello, Ana!
'app-greeting' is not a known element. You forgot to add the class to the imports array of the component that uses it.
Standalone Components
Since Angular 19 components are standalone by default: they declare their own dependencies in imports and do not need an NgModule. Older projects have a line standalone: false or use modules. New code should always be standalone.
Inline Template and Styles
Inline code is nice for tiny components. Use separate files for bigger ones.
The Component Tree
Every Angular app is a tree of components. Data flows down with inputs and events flow up with outputs (a later lesson).
Naming Rules
- Selector uses a prefix and kebab-case:
app-user-card - Class names use PascalCase:
UserCard - One component per file, one folder per feature
Conclusion
A component bundles TypeScript, HTML and CSS. Generate it with ng g c, add it to imports of the parent and use its selector like a custom HTML tag.
<app-name />.

