Master Angular From Scratch

Learn Angular with clear, interactive, and structured lessons for beginners and developers.

ANGULAR COURSE SYLLABUS
1. Angular Introduction
Angular Introduction Angular History Angular Fundamentals Angular Architecture Component-Based Angular
2. Angular Setup
Angular Setup Introduction Installing Node.js Installing Angular CLI Creating an Angular Application Angular Project Structure
3. Components
Components Overview Component Anatomy Creating Components Component Selector Component Template Component Styles Component Metadata Standalone Components Parent and Child Components Reusable Components
4. Templates
Templates Introduction Template Syntax Template Expressions Template Statements Template Reference Variables ng-template ng-container ngTemplateOutlet Built-in Control Flow
5. Data Binding
Data Binding Introduction Interpolation Binding Property Binding Event Binding Two-Way Data Binding Class & Style Binding
6. Directives
Directives Introduction Attribute Directives Structural Directives Custom Directives
7. Pipes
Pipes Introduction Built-in Pipes Parameterized Pipes Chaining Pipes Custom Pipes
8. Event Handling
Event Handling Introduction DOM Events Event Binding Syntax Event Object Passing Data to Event Handlers
9. Input & Output
Component Communication @Input @Output EventEmitter
10. Lifecycle Hooks
Lifecycle Hooks Introduction ngOnInit ngOnChanges ngAfterViewInit ngOnDestroy
11. Services
Services Introduction Creating Angular Services Using Services in Components Sharing Data Through Services Service Scope
12. Dependency Injection
Dependency Injection Introduction Injecting Dependencies InjectionToken Provider Configuration
13. Routing
Routing Introduction Route Configuration RouterLink & Navigation Route Parameters Child Routes Route Guards
14. Forms
Angular Forms Introduction Template-Driven Forms Reactive Forms Form Validation Form Submission & Error Handling
15. HttpClient
HttpClient Introduction Configuring HttpClient GET Request POST, PUT & DELETE Requests Headers & Parameters HTTP Error Handling
16. Observables
Observables Introduction Creating & Subscribing to Observables Observable Data Streams Observable Operators Subscription Management
17. RxJS
RxJS Introduction RxJS Operators Transformation & Filtering Combining Observables Higher-Order Mapping Subjects
18. API Integration
API Integration Introduction Connecting Angular with REST API Consuming API Data CRUD API Integration API Response & Error Handling

Angular Templates

Angular Templates define the user interface of a component. They combine HTML with Angular template features such as interpolation, property binding, event binding, directives and control flow.

What is an Angular Template?

An Angular template is HTML that Angular uses to display data and respond to user actions.

A component class contains the application data and logic, while the template controls how that data is displayed to the user.

Simple Definition

Component Class + Angular Template = Interactive UI

Angular Template Flow

Component Class

Data & Logic

→
Template

HTML + Angular Syntax

→
Angular

Processes Template

→
Browser

Rendered UI

Basic Angular Template

A simple Angular template can contain normal HTML elements.

student.component.html
<h2>Student Details</h2>
<p>Welcome to Angular Training</p>
Expected Output:

Student Details

Welcome to Angular Training

Template with Component Data

Angular templates can display values stored inside the component class.

student.component.ts
export class StudentComponent {

    studentName = 'Sam';
    courseName = 'Angular Full Stack';

}
student.component.html
<h2>Student Information</h2>

<p>Student Name: {{ studentName }}</p>

<p>Course: {{ courseName }}</p>
Expected Output:

Student Information

Student Name: Sam

Course: Angular Full Stack

Important Angular Template Features

Interpolation

Displays component values inside HTML.

{{ studentName }}
Property Binding

Binds a component value to an element property.

[value]="studentName"
Event Binding

Responds to user-generated events.

(click)="save()"
Two-Way Binding

Synchronizes data between component and UI.

[(ngModel)]="name"

Interpolation

Interpolation is used to display component data in the template. It uses double curly braces.

Interpolation Example
export class StudentComponent {

    name = 'Pradnya';

}
Template
<h2>Welcome {{ name }}</h2>
Expected Output:

Welcome Pradnya

Property Binding

Property binding connects an HTML element property with a component property.

Property Binding Example
export class StudentComponent {

    imageUrl = 'assets/student.jpg';

}
Template
<img [src]="imageUrl" alt="Student">
Component imageUrl
→
Property Binding [src]
→
HTML img element

Event Binding

Event binding allows the template to respond to user actions such as clicks.

Component
export class StudentComponent {

    message = '';

    showMessage() {
        this.message = 'Welcome Sam!';
    }

}
Template
<button (click)="showMessage()">
    Show Message
</button>

<p>{{ message }}</p>
Expected Behavior:

When the user clicks Show Message, the message Welcome Sam! is displayed.

Two-Way Data Binding

Two-way binding keeps the component property and input control synchronized.

Example
export class StudentComponent {

    studentName = '';

}
Template
<input
    [(ngModel)]="studentName"
    placeholder="Enter student name">

<p>Student: {{ studentName }}</p>
Component studentName
↔
Two-Way Binding [(ngModel)]
↔
Input User Value

Directives in Templates

Angular directives can change the behavior, appearance or structure of elements in a template.

Attribute Directives

Modify the appearance or behavior of elements.

ngClass
Structural Concepts

Control which content appears in the UI.

if / for
Custom Directives

Develop application-specific behavior.

appHighlight

Template Expressions

Angular templates can evaluate expressions to display calculated values.

Example
export class StudentComponent {

    marks = 85;
    total = 100;

}
Template
<p>Marks: {{ marks }} / {{ total }}</p>

<p>Percentage: {{ (marks / total) * 100 }}%</p>
Expected Output:

Marks: 85 / 100

Percentage: 85%

Template Reference Variables

A template reference variable can provide a convenient reference to an element or directive instance within the template.

Example
<input #studentInput placeholder="Enter name">

<button (click)="showName(studentInput.value)">
    Show Name
</button>
How it works

The #studentInput variable references the input element so its current value can be used in the template.

Template Architecture

Component Data

Properties and methods defined in the component class.

→
Angular Template

HTML combined with Angular template syntax.

→
User Interface

Angular renders the final interface in the browser.

Template Best Practices

  • Keep templates simple and easy to read.
  • Avoid putting complex business logic directly in templates.
  • Use meaningful component property names.
  • Break large interfaces into reusable components.
  • Use Angular binding features instead of manually manipulating the DOM.
  • Keep repeated UI logic reusable through components and directives.

Summary

Angular Templates define the visual structure and interaction of an Angular component.

Important template features include Interpolation, Property Binding, Event Binding, Two-Way Binding, Directives and Template Reference Variables.

A good Angular template should be readable, maintainable and focused mainly on presenting and interacting with application data.