Advantages of ChangeDetectionStrategy - OnPush

In previous section you have learned about ChangeDetectionStrategy using both default and OnPush options.

Some of the advantages of using OnPush option over default are given:

  1. It helps in increasing the performance of our Angular applications.
  2. Angular doesn't have to traverse the entire component tree structure for detecting individual changes on properties.
  3. Angular internally can skip the nested tree structures when inputted properties don't change.

To understand it better, let's create a use case. For that first we need to create a new component named change-detect using Angular CLI ng command.

Once the component is created, you should see the output as shown in the following screenshot: ...

Get Expert Angular now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.