N
Nisha Allam

Posted on 25th April 2024|78 views

0
votes

What Is The Difference Between Constructor And NgOnInit

By default, angular provides life cycle hook ngOnInit. Why should ngOnInit be used, if we already have a constructor?

Answers
P
Ishika A

Posted on 25th April 2024

A constructor is a method which is called whenever an object is created. It is generally used for initializing class members. In Angular, ngOnInit() is one of the component's life hooks called to indicate that component is initialized.

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos