Angular Cookbook

Listening Options



Your Own Angular Cheat Sheet with the Angular Cookbook 2nd Edition

Welcome back, folks, to! In today's blog, we dive into an exciting resource for Angular developers: the Angular Cookbook, 2nd Edition by Mohammad. Whether you're a seasoned pro or just getting started with Angular, this book has you covered with practical recipes designed to solve real-world problems.

Let's explore Mohammad’s journey, the highlights of the cookbook, and the invaluable insights it brings to the Angular community.

Meet Mohammad

Before we get into the intricacies of the Angular Cookbook, let’s get to know Mohammad and his impressive journey from Pakistan to becoming a Google Developer Expert and author.

Early Days in Karachi

Mohammad hails from Karachi, Pakistan, a city known as the tech hub of the country. Although it has faced challenges over the years, Karachi remains a significant center of economic activity. Mohammad recounts:

"Karachi collects 35% of Pakistan's tax revenue and generates approximately 25% of the entire GDP."

Growing up in a small town within Karachi, Mohammad had to travel long hours for education. Despite the hardships, he maintained a passion for learning and focused particularly on coding subjects.

Journey into Development

Mohammad's foray into development began in 2013, when he joined a company as a software engineer, tasked with transitioning from Flash to HTML5. This was his introduction to Angular, and he was immediately captivated by its capabilities:

"When I went to the Angular site, I could just type something right in the site and I did not have to bind any event listeners on anything at all. But then magically, there was two-way data binding. I was fascinated by that."

Through dedication and contributions to open source projects, Mohammad quickly advanced in his career, eventually becoming a senior software engineer and leading small teams.

Transition to Sweden

In his quest for new challenges, Mohammad moved to Sweden to work with Klarna, a unicorn company specializing in online financial services. His time at Klarna involved extensive work with React and React Native, but his love for Angular never waned.

Becoming a Google Developer Expert (GDE)

Inspired and mentored by Mahoud, the second GDE from Pakistan, Mohammad embarked on a journey to build his portfolio and contribute to the community. His notable achievements include creating the NGX Device Detector, a library widely used in the Angular ecosystem.

"End of creating this thing called NGX Device Detector, which is right now one of the very famous libraries for Angular. We recently crossed, I think, 10 million downloads."

In 2018, Mohammad's hard work paid off when he received the prestigious GDE title, marking a significant milestone in his career.

The Angular Cookbook 2nd Edition

Fast forward to today, Mohammad has authored the Angular Cookbook 2nd Edition, a comprehensive guide designed to help Angular developers tackle common challenges with practical solutions.

Why the Angular Cookbook?

The idea for the cookbook stemmed from the need to bridge the gap between complex documentation and real-world applications. PACT reached out to Mohammad with the idea, and he put together an outline that addressed common problems faced by developers. The goal was to create a resource that follows the pattern of:

  1. Identifying the Problem
  2. Implementing the Solution
  3. Explaining How It Works
"The idea was to give something that follows the pattern of how I think a lot of developers learn. That is by implementing something and seeing and figuring out if this works or not, rather than a lot of text."

Writing Process and Teamwork

Creating the cookbook was no small feat. Mohammad collaborated with editors and technical reviewers to ensure the highest quality. Here’s a look into the process:

  1. Writing the Chapter: Mohammad wrote each chapter, detailing the problem, solution, and implementation specifics.
  2. Technical Review: A reviewer tested the code to ensure it worked as described.
  3. Grammar and Style Check: Editors refined the text for clarity and accuracy.
"One of the things that actually spilled over even after publishing was that just yesterday or the day before yesterday, I've upgraded all the logos of Angular to the new one."

Standout Features of the Cookbook

The Angular Cookbook covers a vast array of topics, from basic Angular principles to advanced performance optimizations. Here are some standout recipes and features:

Defer Blocks

One of the game-changing recipes in the cookbook is Using Defer Blocks for Lazy Loading. This technique significantly reduces the initial load time of applications by loading components only when necessary.

@Component({selector: 'app-defer-block',template: `<ng-template #loading><p>Loading...</p></ng-template><ng-template [defer]="true" [loadingTemplate]="loading"><app-heavy-component></app-heavy-component></ng-template>`})export class DeferBlockComponent {}
"Now we got the drag and drop component right here. And until that appears, you also saw a bit of a tiny loader there. This is while the component is being loaded."

Progressive Web Applications (PWAs)

The cookbook delves into creating PWAs with Angular, complete with a fun dice-rolling game example. This recipe covers service workers, caching strategies, and offline capabilities.

// Registering a service worker in Angularimport { ServiceWorkerModule } from '@angular/service-worker';import { environment } from '../environments/environment';@NgModule({declarations: [ ... ],imports: [...,ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),],...})export class AppModule { }

Form Arrays

Another practical recipe is working with Form Arrays in Angular. This section teaches how to dynamically create, add, and remove form controls.

// Creating a form with FormArraythis.myForm ={items: this.fb.array([this.createItem()])});createItem(): FormGroup {return{name: '',quantity: ''});}

Performance Optimizations

The cookbook also offers invaluable tips for optimizing Angular applications, such as using Web Workers for heavy computations.

// Utilizing Web Workers in Angularif (typeof Worker !== 'undefined') {const worker = new Worker('./app.worker', { type: 'module' });worker.onmessage = ({ data }) => {console.log(`Received message from worker: ${data}`);};worker.postMessage('Hello, worker!');}
"One of the things that actually spilled over even after publishing was that just yesterday or the day before yesterday, I've upgraded all the logos of Angular to the new one"


The Angular Cookbook 2nd Edition by Mohammad is more than just a book; it’s a toolkit for developers looking to harness the full power of Angular. From lazy loading with Defer Blocks to creating robust PWAs and optimizing performance with Web Workers, this cookbook provides practical, hands-on recipes for every Angular enthusiast.

Why You Should Get the Angular Cookbook

If you're looking to:

  • Enhance your Angular skills with real-world examples.
  • Solve common problems effortlessly.
  • Optimize your applications for better performance.
  • Stay updated with the latest Angular features and best practices.

Then this cookbook is a must-have! Get your copy today and start cooking up some Angular magic.

For more insightful articles and resources, check out And if you have any questions or would like to share your experience with the Angular Cookbook, feel free to leave a comment below!

Happy coding! 🎉


Alex Patterson