How to set ChangeDetectionStrategy.OnPush as default strategy

It’s not possible to set the global ChangeDetection.

However, it is possible to set it on the CLI, so that all components newly generated using ng generate component (or ng g c) will have it set to OnPush.

Run this command to set it:

ng config schematics.@schematics/angular.component.changeDetection OnPush

Alternatively (this is what this command does), add this block at the base level of your angular.json:

// angular.json
{
  //...
  "schematics": {
    "@schematics/angular": {
      "component": {
        "changeDetection": "OnPush"
      }
    }
  }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)