Understanding Components
Explore Angular 19 components, their creation, and lifecycle.
Understanding Components is a free Angular Academy lesson on CoddyKit — lesson 2 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Angular Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Understanding Angular Components
Components are the building blocks of Angular applications. In this lesson, you'll learn about components and their lifecycle.

2
What is a Component?
A component is a piece of UI that includes HTML, CSS, and TypeScript code. It represents a part of your application's user interface.
3
Creating a Component
Use Angular CLI to create a component easily:
ng generate component my-componentng generate component my-component4
Component Structure
An Angular component usually has four main files:
.html: template.ts: logic.css: styles.spec.ts: testing
5
Component Decorator
The @Component decorator connects your component class to its template and styles.
@Component({
selector: 'app-my-component',
templateUrl: './my-component.html',
styleUrls: ['./my-component.css']
})6
Lifecycle Hooks
Angular components have lifecycle hooks that let you run code at specific points. Common hooks include ngOnInit() and ngOnDestroy().
7
Using ngOnInit()
ngOnInit() runs after Angular initializes component data. It's great for initial setup:
ngOnInit() {
console.log('Component initialized!');
}8
9
Displaying Components
Use your component's selector in other templates to display it:
<app-my-component></app-my-component>10
Summary
You learned about components, how to create them, and their lifecycle hooks. Great job!

Frequently asked questions
Is the “Understanding Components” lesson free?
Yes — the full text of “Understanding Components” is free to read here on the web, and the Angular Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Angular Academy course, upgrade to CoddyKit PRO.
What will I learn in “Understanding Components”?
Explore Angular 19 components, their creation, and lifecycle. You practise Angular Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Angular Academy?
No prior experience is required. Angular Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “Understanding Components” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Angular Academy lesson?
Yes. Every Angular Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Getting Started with Angular 19
- Understanding Components
- Templates and Data Binding