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

Property Binding

Learn how Angular uses property binding to connect component data with HTML element properties dynamically.

What is Property Binding?

Property binding is an Angular data binding technique used to set the properties of HTML elements, components, or directives using values from the component.

Property binding uses square brackets [property] to bind a component value to an element property.

Property Binding Flow

1
Component

Component contains the value.

→
2
Property

HTML property is selected for binding.

→
3
Binding

Angular connects the value with the property.

→
4
UI

The element reflects the bound value.

Main Property Binding Concepts

A
Attribute Properties

Bind values to common HTML element properties.

D
Disabled State

Dynamically enable or disable an element.

I
Image Source

Dynamically set an image source using component data.

C
Class Binding

Dynamically apply CSS classes to elements.

Property Binding Syntax

Property binding uses square brackets around the property name.

Basic Syntax
<element [property]="expression">
</element>

Angular evaluates the expression on the right side and assigns the result to the specified property.

Binding the Disabled Property

Property binding can dynamically control whether a button is enabled or disabled.

Component
export class StudentComponent {

    isDisabled = true;

}
Template
<button [disabled]="isDisabled">
    Submit
</button>
Output:

Binding the Image Source

An image source can be dynamically assigned using property binding.

Component
export class StudentComponent {

    imageUrl = 'assets/images/student.png';

}
Template
<img
    [src]="imageUrl"
    alt="Student">

Angular reads the value of imageUrl and assigns it to the image element's src property.

Binding the Input Value

Property binding can set the initial value of an input element.

Example
studentName = 'Sam';
Template
<input
    [value]="studentName"
    type="text">
Output:

Class Property Binding

A CSS class can be dynamically applied using class property binding.

Example
isActive = true;
Template
<div [class.active]="isActive">
    Student Profile
</div>

When isActive is true, Angular applies the active CSS class to the element.

Style Property Binding

Individual CSS properties can also be dynamically bound.

Example
fontSize = '20px';
Template
<p [style.font-size]="fontSize">
    Angular Full Stack
</p>

Binding to Component Properties

Property binding can also be used with custom component properties.

Parent Component
studentName = 'Sam';
studentCourse = 'Angular Full Stack';
Template
<app-student
    [name]="studentName"
    [course]="studentCourse">
</app-student>

Here the parent component sends values to the child component through property binding.

Property Binding Data Flow

Component
isDisabled = true
→
Binding
[disabled]
→
Angular
Evaluate
→
Element
disabled

Interpolation vs Property Binding

Feature Interpolation Property Binding
Syntax {{ value }} [property]="value"
Purpose Display text Set element properties
Direction Component → Template Component → Element
Example {{ studentName }} [disabled]="isDisabled"
Common Usage Text content Element behavior and properties

Common Uses of Property Binding

1
Button State

Enable or disable buttons dynamically.

2
Images

Dynamically assign image source values.

3
Form Controls

Bind values and states of form elements.

4
CSS Classes

Dynamically apply classes and styles.

Complete Property Binding Example

Student Component
export class StudentComponent {

    studentName = 'Sam';
    isDisabled = false;
    imageUrl = 'assets/images/student.png';

}
Student Template
<div>

    <h2>
        {{ studentName }}
    </h2>

    <input
        [value]="studentName"
        type="text">

    <button
        [disabled]="isDisabled">

        Submit

    </button>

    <img
        [src]="imageUrl"
        alt="Student">

</div>
Student Profile

Name: Sam

Best Practices

1. Use property binding for element properties

Use square bracket syntax when dynamically setting an element property.

2. Keep binding expressions simple

Avoid complex logic directly inside property bindings.

3. Use interpolation for text

When you only need to display text, interpolation is often the clearer choice.

4. Use meaningful property names

Clear component property names make bindings easier to understand.

5. Avoid unnecessary bindings

Add bindings only where the UI actually depends on component data.

Summary

  • Property binding connects component data with element properties.
  • It uses square bracket syntax such as [disabled].
  • It can dynamically control element states and values.
  • Property binding can be used with HTML elements and components.
  • Class and style properties can also be dynamically bound.
  • Property binding is a one-way data binding technique.