• Overview
@angular/router

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.

  
    class RouterModule {}
  
  

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 {}
@paramroutesRoutes

An array of Route objects that define the navigation paths for the application.

@paramconfigExtraOptions | undefined

An ExtraOptions configuration object that controls how navigation is performed.

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 {}
@paramroutesRoutes

An array of Route objects that define the navigation paths for the submodule.

Jump to details