adspace


Explain the difference between constructor and ngoninit in angular 6?

Answer Posted / Meghna Singh

In Angular, the Constructor is a method that is called when an instance of a component or service is created. It is used to initialize properties and set up dependencies. The `ngOnInit` lifecycle hook, on the other hand, is called after the component's properties have been initialized and is used to perform any additional setup or initialization that requires data from services or other sources.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Angularjs dependency injection of value inside of the module.config?

893


How an object or function can get a hold of its dependencies?

853


How to implement a datagrid table with angular 2 and primeng?

890


What is the latest version of angular?

979


Give the example of angularjs strings?

876


How can primeng be used with angular2?

945


How to use primeng in angular 4?

947


How to enable html5 mode in angular 1.x?

925


What is a dynamic route in angularjs and how do you implement it?

862


What is the latest angular?

809


Which version you are using js?

946


How to get and log an error in angular 4?

875


How to create angularjs filter which outputs html?

860