Angular Tutorial 120 lessons · 2:23:08+ of video
Angular Home What Angular Is, Where Angular Is Used and How Angular Works
What Angular Is Where Angular Is Used How Angular Works What You Need, Creating a Project and The Project Structure
What You Need Creating a Project The Project Structure The Root Component, ng serve and Your First Change
The Root Component ng serve Your First Change Why TypeScript, Basic Types and Interfaces
Why TypeScript Basic Types Interfaces Classes, Optional and Union Types and Arrays and Generics
Classes Optional and Union Types Arrays and Generics Decorators, import and export and Practice: Typed Books
Decorators import and export Practice: Typed Books Components, Templates and Interpolation
Components Templates Interpolation Property Binding, Event Binding and ng generate component
Property Binding Event Binding ng generate component Using Components Together, Component Styles and Practice: A Book Card
Using Components Together Component Styles Practice: A Book Card What Signals Are, signal() and set() and update()
What Signals Are signal() set() and update() computed(), effect() and Signals with Arrays
computed() effect() Signals with Arrays Signals with Objects, linkedSignal() and Practice: A Counter and a Basket
Signals with Objects linkedSignal() Practice: A Counter and a Basket @if, @else and @else if and @for
@if @else and @else if @for track, @empty and @switch
track @empty @switch @let, Class and Style Bindings and Practice: A Book List
@let Class and Style Bindings Practice: A Book List Parent and Child, input() and Required Inputs and Defaults
Parent and Child input() Required Inputs and Defaults output(), Sending Data Up and model() for Two-Way Binding
output() Sending Data Up model() for Two-Way Binding Content Projection, Building a Small Component Tree and Practice: A Star Rating
Content Projection Building a Small Component Tree Practice: A Star Rating Pipes, Built-in Pipes and Pipe Arguments
Pipes Built-in Pipes Pipe Arguments Custom Pipes, Directives and Custom Attribute Directives
Custom Pipes Directives Custom Attribute Directives host Listeners, Template Reference Variables and Practice: A Price List
host Listeners Template Reference Variables Practice: A Price List Why Services, Creating a Service and inject()
Why Services Creating a Service inject() @Service and @Injectable, Sharing State in a Service and Signals in Services
@Service and @Injectable Sharing State in a Service Signals in Services Providers, Injection Tokens and Practice: A Wishlist Service
Providers Injection Tokens Practice: A Wishlist Service What Routing Is, Routes and router-outlet and routerLink
What Routing Is Routes and router-outlet routerLink Route Parameters, Navigating in Code and Redirects and Not Found
Route Parameters Navigating in Code Redirects and Not Found Lazy Loading, Route Guards and Practice: Book Pages
Lazy Loading Route Guards Practice: Book Pages Forms in Angular, Template-Driven Forms and Reactive Forms
Forms in Angular Template-Driven Forms Reactive Forms FormGroup, Validators and Showing Errors
FormGroup Validators Showing Errors Signal Forms, Custom Validators and Practice: A Signup Form
Signal Forms Custom Validators Practice: A Signup Form Talking to a Server, HttpClient and GET Requests
Talking to a Server HttpClient GET Requests Observables Basics, POST, PUT and DELETE and Loading and Errors
Observables Basics POST, PUT and DELETE Loading and Errors httpResource, Interceptors and Practice: A Books Client
httpResource Interceptors Practice: A Books Client RxJS Basics, map and filter and Search with debounceTime
RxJS Basics map and filter Search with debounceTime toSignal(), Why Test and Testing a Component
toSignal() Why Test Testing a Component Testing a Service, Testing User Actions and Practice: Test the Basket
Testing a Service Testing User Actions Practice: Test the Basket Building for Production, @defer and Deploying
Building for Production @defer Deploying Project: The Plan, Models and Service and The Book List
Project: The Plan Project: Models and Service Project: The Book List Project: The Book Page, The Basket and Checkout Form
Project: The Book Page Project: The Basket Project: Checkout Form Project: Tests, Where to Go Next and Course Recap
Project: Tests Where to Go Next Course Recap Angular · Lesson 22 of 120
Property Binding [property]="value".
⏱ 2 min read ▶ Video at 26:40 🎓 Free
▶ starts at 26:40 Interpolation puts values into text. But sometimes we want to set a property of an element. Like the picture an image shows, or whether a button is disabled.
Not just text Element properties src, disabled, style Square brackets around a property name bind it to a value from the class. The right side is TypeScript, not text. When the value changes, the property updates. And style dot colour sets a single style, the same way.
key value [src]="cover" the image to show [disabled]="stock === 0" on or off [style.color]="..." one style Right side a TypeScript expression
The image source is bound to cover, a picture from the class. The heading's title, the text you see when hovering, is built from the author. The button is disabled, when the stock is zero. And the stock colour turns red, when it's sold out. Run it. Dune is out of stock, so the button is greyed out, and the stock is red.
app.ts typescript Copy
import { Component } from '@angular/core' ;
import { COVER } from './cover' ;
@ Component ({
selector: 'app-root' ,
template: `
<img [src]="cover" [alt]="title" width="90">
<h2 [title]="'Written by ' + author">{{ title }}</h2>
<button [disabled]="stock === 0">Add to basket</button>
<p [style.color]="stock === 0 ? 'crimson' : 'green'">Stock: {{ stock }}</p>
` ,
})
export class App {
cover = COVER ;
title = 'Dune' ;
author = 'Frank Herbert' ;
stock = 0 ;
} Also uses cover.ts export const COVER = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='170'%3E%3Crect width='120' height='170' rx='8' fill='%23c3002f'/%3E%3Ctext x='60' y='95' font-size='26' font-family='Helvetica' fill='white' text-anchor='middle'%3EDune%3C/text%3E%3C/svg%3E" ; Prefer to watch? The full Angular course is free All lessons in one video with animations, real code and chapters.
Watch free With square brackets, the right side is code, so a name means a property of the class. Without them, it's just fixed text. So square brackets src equals cover, shows the cover. But src equals cover, without brackets, looks for a file called cover.
[src]="cover" codethe class's covervalue can change src="cover" plain texta file named covernever changes Square brackets bind an element property to a value from the class, and update it when the value changes. Next, event binding.
Key takeaways [src] [disabled] [style.color]