logo-MindMajix
N
Nisha Allam

Posted on 16th June 2024|80 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?

1 answers
Answers
P
Ishika A

Posted on 16th June 2024| views

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
Name
Course *
Email *
Phone Number