Tutorials, guides and articles on Angular framework.

Change Detection in Angular: Default vs OnPush

One of the most loved features of Angular is its ability to automatically update the view whenever data changes. This is thanks to the default Angular's change detection mechanism, which constantly checks for changes in data and updates the view accordingly. While this is great for most use cases, it…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:7 mins read
Continue ReadingChange Detection in Angular: Default vs OnPush

Generating Routes File for Angular Universal Prerender

In this blog post, I will show you how to generate a routes file for prerendering an Angular Universal application. We will create a basic routes file and append routes dynamically from an XML sitemap ahead of running npm run prerender command when building the application. Pre-requisites This post assumes…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:6 mins read
Continue ReadingGenerating Routes File for Angular Universal Prerender

Fixing Angular Unit Tests: Cannot read property ‘range’ of undefined

While upgrading Node from v12 to v16, I came across a problem with Angular unit tests where an exception would stop the test run with error Cannot read property 'range' of undefined. In this post, I'll explain the steps I took to identify the root cause of issue and propose…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:6 mins read
Continue ReadingFixing Angular Unit Tests: Cannot read property ‘range’ of undefined

Angular Universal: Setting HTTP Status Code

Angular Universal gives superpowers to traditional Angular apps such as server-side rendering (SSR) and full features using Express.js server. This allows us to implement features like returning HTTP status codes in appropriate scenarios. In this post, I will show you how to set the HTTP status code from an Angular…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:7 mins read
Continue ReadingAngular Universal: Setting HTTP Status Code

Error: Cannot resolve type entity i3.DialogModule to symbol

While updating my Angular Material Starter Template to Angular 14, I ran into an error causing broken builds. The console output seems to suggest this is a problem with Dialog module from Angular Component Dev Kit (CDK): Cannot resolve type entity i3.DialogModule to symbol. ./src/polyfills.ts - Error: Module build failed…

  • Post category:Angular
  • Post comments:1 Comment
  • Reading time:3 mins read
Continue ReadingError: Cannot resolve type entity i3.DialogModule to symbol

Using ng-deep in Angular

ng-deep is a special selector in Angular that you should use very carefully. I often come across ng-deep in code reviews, where I investigate further to see if it is really necessary. In this post, I will talk a little bit about ng-deep: what it does, where it is useful…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:6 mins read
Continue ReadingUsing ng-deep in Angular

Making Styles Work with [innerHtml] in Angular

In this post, we'll look at how we can apply styles to html content rendered via innerHtml attribute. By default, styles defined in an Angular component only work in that specific component. This is due to the Emulated view encapsulation policy set by Angular. This logical scope is great because…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:4 mins read
Continue ReadingMaking Styles Work with [innerHtml] in Angular

How to Queue Messages Sent to LiveAnnouncer

Angular provides LiveAnnouncer service to trigger screen reader announcements programmatically. It works well in simple scenarios but fails to queue messages when used concurrently. In this post, I will show you how to extend LiveAnnouncer to announce simultaneous messages. Problem demonstration There are many things to consider when it comes…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:5 mins read
Continue ReadingHow to Queue Messages Sent to LiveAnnouncer

5 Angular CLI Tips You Should Know

As Angular developers, we often interact with the command-line interface (CLI) to scaffold components and manage packages. It is very important to master the CLI to make sure your development flow is smooth. Having developed several Angular applications myself, I have come to realise the 5 tips below. Shorten commands…

  • Post category:Angular
  • Post comments:0 Comments
  • Reading time:6 mins read
Continue Reading5 Angular CLI Tips You Should Know

Monitoring Live Angular Apps with Application Insights

In this post, I will explain how you can monitor Angular apps using Microsoft Azure Application Insights. It is not unusual for organisations to ignore monitoring single page applications. Usually, back-end applications such as APIs are monitored via logs, CPU and memory usage. When it comes to front-end, there is…

Continue ReadingMonitoring Live Angular Apps with Application Insights