What is the purpose of forroot method in angular 4?



What is the purpose of forroot method in angular 4?..

Answer / Sukh Beer Singh

The forRoot() method in Angular 4 (actually Angular 2 and up) is used when you need to create and register a service that should be available throughout the entire application, such as a shared service. The forRoot() method typically returns an instance of the service along with metadata about the module it belongs to, which allows Angular to manage the lifecycle of the service properly.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

What is route params?

1 Answers  


Differentiate between ng-Class and ng-Style?

1 Answers  


List out the differences between config and run methods in angularjs?

1 Answers  


What is ngoninit in angular?

1 Answers  


How to enable html5 mode in angular 1.x?

0 Answers  


Mention what are the advantages of using angularjs?

1 Answers  


How to use styleurls and styles in angular?

1 Answers  


What is backend javascript?

1 Answers  


What are AngularJS features? 15

1 Answers  


What is the use of pipe in rxjs?

1 Answers  


What is a decorator in angular?

1 Answers  


What is the use of typescript in angular2?

1 Answers  


Categories