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 11 of 120
Basic Types String, number, boolean.
⏱ 2 min read ▶ Video at 12:21 🎓 Free
▶ starts at 12:21 Let's meet the types you'll use every day. They're simple, and there are only a few.
Everyday types Simple Only a few String is text, in quotes. Number is any number, whole, or with decimals. Boolean is true, or false. And any switches type checking off, so avoid it.
Type Values Example string text "Dune" number any number 9.99, 3 boolean true or false true any anything (avoid) no checks
A colon after the name gives the variable a type. Title is a string, price is a number, and in stock is a boolean. Copies has no type written. TypeScript works it out from the value, three, so it's a number. Run it. All four values print. And copies can grow by one, because it's a number.
main.ts typescript Copy
let title : string = "Dune" ;
let price : number = 9.99 ;
let inStock : boolean = true ;
let copies = 3 ;
console. log (title, price, inStock, copies);
copies = copies + 1 ;
console. log ( `Copies now: ${ copies }` ); Output
Dune 9.99 true 3
Copies now: 4 Also uses _mode ts Now we put text into price, and into copies. Both should be numbers. Run it. TypeScript reports both lines. Even copies is protected, although we never wrote its type.
main.ts typescript Copy
let title : string = "Dune" ;
let price : number = 9.99 ;
let copies = 3 ;
price = "cheap" ;
copies = "three" ; Output
main.ts(5,1): error TS2322: Type 'string' is not assignable to type 'number'.
main.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. Also uses _mode ts Prefer to watch? The full Angular course is free All lessons in one video with animations, real code and chapters.
Watch free Parameters get types, the same way. The type after the brackets is what the function returns. Price with tax returns a number, and shout returns a string. Run it. Ten plus twenty percent is twelve. And shout returns SALE, with an exclamation mark.
main.ts typescript Copy
function priceWithTax ( price : number , rate : number ) : number {
return Math. round (price * ( 1 + rate) * 100 ) / 100 ;
}
function shout ( text : string ) : string {
return text. toUpperCase () + "!" ;
}
console. log ( priceWithTax ( 10 , 0.2 ));
console. log ( shout ( "sale" )); Also uses _mode ts Use string, number, and boolean, with a colon. TypeScript also works out types by itself. Next, interfaces.
Key takeaways let price: number Inferred types Return types