prefer-on-push-cd-strategy
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 {
}