Q. How do you mark a component to use OnPush change detection?

  • (A) Add changeDetection: ChangeDetectionStrategy.OnPush in @Component
  • (B) Add @OnPush decorator to class
  • (C) Import OnPushModule
  • (D) Use ngOnChanges lifecycle hook
πŸ’¬ Discuss
βœ… Correct Answer: (A) Add changeDetection: ChangeDetectionStrategy.OnPush in @Component
Explanation: OnPush strategy improves performance by checking only when input references change.
Explanation by: Mr. Dubey
OnPush strategy improves performance by checking only when input references change.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
92
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
92%
Success Rate