top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Angular 2.0: What is the difference between a module's forRoot() and forChild() methods and why do we need it?

0 votes
279 views
Angular 2.0: What is the difference between a module's forRoot() and forChild() methods and why do we need it?
posted Dec 4, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Call forRoot for root application module, AppModule. Calling it in any other module, particularly in a lazy loaded module

forRoot creates a module that contains all the directives, the given routes, and the router service itself.

Call forChild for child modules.

forChild creates a module that contains all the directives and the given routes, but does not include the router service.

answer Jan 24, 2018 by Manish Tiwari
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...