March 2017
Intermediate to advanced
118 pages
2h 1m
English
In this last chapter we will look at configuring the router.
We configure the router by importing RouterModule, and there are two ways to do it:
RouterModule.forRoot
and
RouterModule.forChild
.
RouterModule.forRoot
creates a module that contains all the router directives, the given routes, and the router service itself. And
RouterModule.forChild
creates a module that contains all the directives and the given routes, but does not include the service.
The router library provides two ways to configure the module because it deals with a shared mutable resource—location. That is why we cannot have more than one router service active—they would clobber each other. Therefore we can use
forChild
to ...
Read now
Unlock full access