Skip to main content

prefer-on-push-cd-strategy

added in: 1.6.0

Prefer setting changeDetection: ChangeDetectionStrategy.OnPush in Angular @Component annotations. OnPush strategy should be used as the default because using Default strategy leads to performance issues.

Example

❌ Bad:

(
selector: 'component-selector',
templateUrl: 'component.html',
styleUrls: ['component.css'],
directives: <Object>[
coreDirectives,
],
)
class Component {
}

✅ Good:

(
selector: 'component-selector',
templateUrl: 'component.html',
styleUrls: ['component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
directives: <Object>[
coreDirectives,
],
)
class Component {
}