#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
4 min read
Question 45 of 46medium

DestroyRef

Cleanup without ngOnDestroy.

What is DestroyRef?

DestroyRef provides a way to register cleanup callbacks without implementing ngOnDestroy. Works with inject().

Benefits

  • No interface implementation
  • Works with functional patterns
  • Can be injected anywhere