Year: 2022
-
Step-by-Step Understanding the Async Pipe
The async pipe can make a huge difference in your change detection strategy for your Angular app. If it’s been confusing to you so far, come work through this step-by-step explanation. We’ll understand it together! In Angular, the async pipe is a pipe that essentially does these three tasks: Also, as a best practice, it…
-
Making Angular Service – Always Singleton
By default, Angular Services are Singleton. When you create a service using the CLI command, ng g s App Angular creates a service named AppService. The above service is Singleton Tree-shakeable Available throughout the application Singleton means Angular creates only one object of the AppService, regardless of how many places you use it. However, if…
-
Angular 14 – Introducing Standalone Components
Angular 14 introduces Standalone Components. A component that is not part of ngModule.
-
The simplest way to disable console.log for Production build in Angular?
I work with different developers, and most of them rely on console.log () or other console methods for development. They use the console to print various values to debug while doing the development. I call this approach console-driven development. Cool name, right? These console functions become overwhelming in production as users can see many things…
-
Make all properties optional using Partial in TypeScript
The utility type Partial<Type> makes all properties of a type optional. Using a scenario, let us try to understand Partial<T> in TypeScript. So, you have a type called Product, that is created as below: export interface Product { Id: string; Title: string; Price: number; inStock: boolean; Quantity: number; } And there is a function to update the price of a product as shown…