Reactive forms

Reactive forms are model-driven: you define the form structure and validation logic in your TypeScript code, then bind it to the template. They are more powerful and scalable than template-driven forms. 1️⃣ Import ReactiveFormsModule In app.module.ts: import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { ReactiveFormsModule } from '@angular/forms';…

0 Comments

Template-driven forms

Template-driven forms are simpler and rely heavily on Angular directives in the template rather than creating a form model in the TypeScript component. They are suitable for simple forms. 1️⃣ Import FormsModule First, you need to import FormsModule in your module (app.module.ts): import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser';…

0 Comments

Observable and Subject in RxJS

1. Observable An Observable is a stream of data that you can subscribe to. It’s cold by default, meaning it doesn’t emit values until someone subscribes. Example: import { Observable } from 'rxjs'; const observable = new Observable<number>((subscriber) => { subscriber.next(1); subscriber.next(2); subscriber.next(3); subscriber.complete(); // completes the stream }); observable.subscribe({ next: (value) => console.log('Received:',…

0 Comments

RxJS operators

RxJS (Reactive Extensions for JavaScript) uses Observables to handle asynchronous data streams, and operators help you manipulate these streams. Operators are usually divided into creation, transformation, filtering, combination, and utility operators. Here’s a detailed overview: 1. Creation Operators These operators are used to create Observables. of Emits a sequence of values you provide. import…

0 Comments

Interceptors in Angular

In Angular, an interceptor is a service that intercepts HTTP requests or responses before they reach the server or the component. Interceptors are part of Angular's HttpClient module and are commonly used for: Adding headers (e.g., authentication tokens) Logging requests/responses Handling errors globally Modifying requests or responses How Interceptors Work When you make an…

0 Comments

HttpClient Module

In Angular, the HttpClient module is a built-in service that allows your application to communicate with backend services over HTTP. It is part of the @angular/common/http package and is the modern, recommended way to make HTTP requests in Angular. Here’s a detailed breakdown: 1. Purpose HttpClient is used to: Fetch data from a server…

0 Comments

RouterModule in Angular

In Angular, the RouterModule is a core module that provides navigation and routing capabilities for single-page applications (SPAs). It allows you to define routes, navigate between different components, and handle parameters, guards, lazy loading, and more. Let’s break it down step by step. 1. Importing RouterModule You need to import RouterModule in your application’s…

0 Comments

Route Guards in Angular

In Angular, Route Guards are used to control access to routes. They act like gatekeepers—allowing or preventing navigation to a route based on some logic, such as authentication, role permissions, or unsaved changes. Angular provides five types of route guards. Let’s go through them step by step. 1. Types of Route Guards GuardWhen It…

0 Comments

Lifecycle Hooks

In Angular, lifecycle hooks are special methods that allow you to tap into key moments of a component or directive’s life — from creation to destruction. These hooks let you execute custom logic at specific points in the component’s life cycle. Angular provides several built-in hooks. Here’s a structured breakdown: 1. ngOnChanges Called: Whenever…

0 Comments

Prettier

Prettier is an opinionated code formatter. It automatically formats your code so that it follows consistent style rules. It supports many programming languages, including: JavaScript / TypeScript HTML / CSS / SCSS JSON / YAML / Markdown Python (via plugins) And more It does not check for errors or bugs—it just makes your code…

0 Comments

End of content

No more pages to load