RouterModule
NgModule
Adds directives and providers for in-app navigation among views defined in an application.
Use the Angular Router
service to declaratively specify application states and manage state
transitions.
API
Description
class RouterModule {}
forRoot
Creates and configures a module with all the router providers and directives. Optionally sets up an application listener to perform an initial navigation.
When registering the NgModule at the root, import as follows:
@NgModule({ imports: [RouterModule.forRoot(ROUTES)]})class MyNgModule {}
@paramconfig
ExtraOptions | undefined
An ExtraOptions
configuration object that controls how navigation is performed.
@returns
ModuleWithProviders<RouterModule>
forChild
Creates a module with all the router directives and a provider registering routes, without creating a new Router service. When registering for submodules and lazy-loaded submodules, create the NgModule as follows:
@NgModule({ imports: [RouterModule.forChild(ROUTES)]})class MyNgModule {}
@returns
ModuleWithProviders<RouterModule>
Jump to details