What are differences between constructors and oninit?



What are differences between constructors and oninit?..

Answer / Ankur Agarwal

The main difference between a constructor and $onInit in AngularJS is that the constructor initializes the component's properties before any data-binding has occurred, while $onInit gets called once when the component has been initialized and its properties are available.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

What is route snapshot?

1 Answers  


What is @ngmodule in angular 2? Explain

1 Answers  


What is the use of ngfor directive in angular?

1 Answers  


What is latest version of angularjs?

1 Answers  


What is the purpose of a filter in angular?

1 Answers  


Is angular 7 released?

1 Answers  


What is angularjs expression?

1 Answers  


What is ngoninit in angular?

1 Answers  


What’s the difference between form, formgroup, and formcontrol? How do they work together?

1 Answers  


How to display the error message from backend in angular2?

1 Answers  


Which of the following directive is used to initialize an angular app?

1 Answers  


Explain currency filter and when to use it?

1 Answers  


Categories