@angular/router-deprecated

  • Version 2.0.0-rc.2
  • Published
  • No dependencies
  • MIT license

Install

npm i @angular/router-deprecated
yarn add @angular/router-deprecated
pnpm add @angular/router-deprecated

Overview

Overview not available.

Index

Variables

variable ROUTER_BINDINGS

const ROUTER_BINDINGS: any[];

variable ROUTER_DIRECTIVES

const ROUTER_DIRECTIVES: any[];
  • A list of directives. To use the router directives like RouterOutlet and RouterLink, add this to your directives array in the View decorator of your component.

    ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))

    import {Component} from '@angular/core';
    import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from '@angular/router-deprecated';
    @Component({directives: [ROUTER_DIRECTIVES]})
    @RouteConfig([
    {...},
    ])
    class AppCmp {
    // ...
    }
    bootstrap(AppCmp, [ROUTER_PROVIDERS]);

variable ROUTER_PRIMARY_COMPONENT

const ROUTER_PRIMARY_COMPONENT: OpaqueToken;
  • Token used to bind the component with the top-level RouteConfigs for the application.

    ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))

    import {Component} from '@angular/core';
    import {
    ROUTER_DIRECTIVES,
    ROUTER_PROVIDERS,
    RouteConfig
    } from '@angular/router-deprecated';
    @Component({directives: [ROUTER_DIRECTIVES]})
    @RouteConfig([
    {...},
    ])
    class AppCmp {
    // ...
    }
    bootstrap(AppCmp, [ROUTER_PROVIDERS]);

variable ROUTER_PROVIDERS

const ROUTER_PROVIDERS: any[];
  • A list of providers. To use the router, you must add this to your application.

    ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))

    import {Component} from '@angular/core';
    import {
    ROUTER_DIRECTIVES,
    ROUTER_PROVIDERS,
    RouteConfig
    } from '@angular/router-deprecated';
    @Component({directives: [ROUTER_DIRECTIVES]})
    @RouteConfig([
    {...},
    ])
    class AppCmp {
    // ...
    }
    bootstrap(AppCmp, [ROUTER_PROVIDERS]);

variable ROUTER_PROVIDERS_COMMON

const ROUTER_PROVIDERS_COMMON: any[];
  • The Platform agnostic ROUTER PROVIDERS

Functions

function CanActivate

CanActivate: (
hook: (
next: ComponentInstruction,
prev: ComponentInstruction
) => Promise<boolean> | boolean
) => ClassDecorator;
  • Defines route lifecycle hook CanActivate, which is called by the router to determine if a component can be instantiated as part of a navigation.

    Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface. This is because the CanActivate function is called before the component is instantiated.

    The CanActivate hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route or null.

    @CanActivate((next, prev) => boolean | Promise<boolean>)

    If CanActivate returns or resolves to false, the navigation is cancelled. If CanActivate throws or rejects, the navigation is also cancelled. If CanActivate returns or resolves to true, navigation continues, the component is instantiated, and the OnActivate hook of that component is called if implemented.

    ### Example

function RouteConfig

RouteConfig: (configs: RouteDefinition[]) => ClassDecorator;
  • The RouteConfig decorator defines routes for a given component.

    It takes an array of RouteDefinitions.

Classes

class AsyncRoute

class AsyncRoute extends AbstractRoute {}
  • AsyncRoute is a type of RouteDefinition used to route a path to an asynchronously loaded component.

    It has the following properties: - path is a string that uses the route matcher DSL. - loader is a function that returns a promise that resolves to a component. - name is an optional CamelCase string representing the name of the route. - data is an optional property of any type representing arbitrary route metadata for the given route. It is injectable via RouteData. - useAsDefault is a boolean value. If true, the child route will be navigated to if no child route is specified during the navigation.

    ### Example

    import {RouteConfig, AsyncRoute} from '@angular/router-deprecated';
    @RouteConfig([
    new AsyncRoute({path: '/home', loader: () => Promise.resolve(MyLoadedCmp), name:
    'MyLoadedCmp'})
    ])
    class MyApp {}

    @ts2dart_const

constructor

constructor({
name,
useAsDefault,
path,
regex,
regex_group_names,
serializer,
data,
loader,
}: RouteDefinition);

    property aux

    aux: string;

      property loader

      loader: () => Promise<Type>;

        class AuxRoute

        class AuxRoute extends AbstractRoute {}
        • AuxRoute is a type of RouteDefinition used to define an auxiliary route.

          It takes an object with the following properties: - path is a string that uses the route matcher DSL. - component a component type. - name is an optional CamelCase string representing the name of the route. - data is an optional property of any type representing arbitrary route metadata for the given route. It is injectable via RouteData.

          ### Example

          import {RouteConfig, AuxRoute} from '@angular/router-deprecated';
          @RouteConfig([
          new AuxRoute({path: '/home', component: HomeCmp})
          ])
          class MyApp {}

          @ts2dart_const

        constructor

        constructor({
        name,
        useAsDefault,
        path,
        regex,
        regex_group_names,
        serializer,
        data,
        component,
        }: RouteDefinition);

          property component

          component: any;

            class ComponentInstruction

            class ComponentInstruction {}
            • A ComponentInstruction represents the route state for a single component.

              ComponentInstructions is a public API. Instances of ComponentInstruction are passed to route lifecycle hooks, like CanActivate.

              ComponentInstructions are [hash consed](https://en.wikipedia.org/wiki/Hash_consing). You should never construct one yourself with "new." Instead, rely on router's internal recognizer to construct ComponentInstructions.

              You should not modify this object. It should be treated as immutable.

            property componentType

            componentType: any;

              property params

              params: { [key: string]: string };

                property reuse

                reuse: boolean;

                  property routeData

                  routeData: RouteData;

                    property routeName

                    routeName: string;

                      property specificity

                      specificity: string;

                        property terminal

                        terminal: boolean;

                          property urlParams

                          urlParams: string[];

                            property urlPath

                            urlPath: string;

                              class Instruction

                              abstract class Instruction {}
                              • Instruction is a tree of ComponentInstructions with all the information needed to transition each component in the app to a given route, including all auxiliary routes.

                                Instructions can be created using Router#generate, and can be used to perform route changes with Router#navigateByInstruction.

                                ### Example

                                import {Component} from '@angular/core';
                                import {bootstrap} from '@angular/platform-browser/browser';
                                import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from
                                '@angular/router-deprecated';
                                @Component({directives: [ROUTER_DIRECTIVES]})
                                @RouteConfig([
                                {...},
                                ])
                                class AppCmp {
                                constructor(router: Router) {
                                var instruction = router.generate(['/MyRoute']);
                                router.navigateByInstruction(instruction);
                                }
                                }
                                bootstrap(AppCmp, ROUTER_PROVIDERS);

                              constructor

                              constructor(
                              component: ComponentInstruction,
                              child: Instruction,
                              auxInstruction: { [key: string]: Instruction }
                              );

                                property auxInstruction

                                auxInstruction: { [key: string]: Instruction };

                                  property child

                                  child: Instruction;

                                    property component

                                    component: ComponentInstruction;

                                      property specificity

                                      specificity: string;

                                        property urlParams

                                        urlParams: string[];

                                          property urlPath

                                          urlPath: string;

                                            method replaceChild

                                            replaceChild: (child: Instruction) => Instruction;
                                            • Returns a new instruction that shares the state of the existing instruction, but with the given child Instruction replacing the existing child.

                                            method resolveComponent

                                            abstract resolveComponent: () => Promise<ComponentInstruction>;

                                              method toLinkUrl

                                              toLinkUrl: () => string;

                                                method toRootUrl

                                                toRootUrl: () => string;
                                                • converts the instruction into a URL string

                                                method toUrlPath

                                                toUrlPath: () => string;
                                                • If the final URL for the instruction is ``

                                                method toUrlQuery

                                                toUrlQuery: () => string;

                                                  class Redirect

                                                  class Redirect extends AbstractRoute {}
                                                  • Redirect is a type of RouteDefinition used to route a path to a canonical route.

                                                    It has the following properties: - path is a string that uses the route matcher DSL. - redirectTo is an array representing the link DSL.

                                                    Note that redirects **do not** affect how links are generated. For that, see the useAsDefault option.

                                                    ### Example

                                                    import {RouteConfig, Route, Redirect} from '@angular/router-deprecated';
                                                    @RouteConfig([
                                                    new Redirect({path: '/', redirectTo: ['/Home'] }),
                                                    new Route({path: '/home', component: HomeCmp, name: 'Home'})
                                                    ])
                                                    class MyApp {}

                                                    @ts2dart_const

                                                  constructor

                                                  constructor({
                                                  name,
                                                  useAsDefault,
                                                  path,
                                                  regex,
                                                  regex_group_names,
                                                  serializer,
                                                  data,
                                                  redirectTo,
                                                  }: RouteDefinition);

                                                    property redirectTo

                                                    redirectTo: any[];

                                                      class RootRouter

                                                      class RootRouter extends Router {}

                                                        constructor

                                                        constructor(registry: RouteRegistry, location: Location, primaryComponent: Type);

                                                          method commit

                                                          commit: (
                                                          instruction: Instruction,
                                                          _skipLocationChange?: boolean
                                                          ) => Promise<any>;

                                                            method dispose

                                                            dispose: () => void;

                                                              class Route

                                                              class Route extends AbstractRoute {}
                                                              • Route is a type of RouteDefinition used to route a path to a component.

                                                                It has the following properties: - path is a string that uses the route matcher DSL. - component a component type. - name is an optional CamelCase string representing the name of the route. - data is an optional property of any type representing arbitrary route metadata for the given route. It is injectable via RouteData. - useAsDefault is a boolean value. If true, the child route will be navigated to if no child route is specified during the navigation.

                                                                ### Example

                                                                import {RouteConfig, Route} from '@angular/router-deprecated';
                                                                @RouteConfig([
                                                                new Route({path: '/home', component: HomeCmp, name: 'HomeCmp' })
                                                                ])
                                                                class MyApp {}

                                                                @ts2dart_const

                                                              constructor

                                                              constructor({
                                                              name,
                                                              useAsDefault,
                                                              path,
                                                              regex,
                                                              regex_group_names,
                                                              serializer,
                                                              data,
                                                              component,
                                                              }: RouteDefinition);

                                                                property aux

                                                                aux: string;

                                                                  property component

                                                                  component: any;

                                                                    class RouteData

                                                                    class RouteData {}
                                                                    • RouteData is an immutable map of additional data you can configure in your Route.

                                                                      You can inject RouteData into the constructor of a component to use it.

                                                                      ### Example

                                                                      import {Component} from '@angular/core';
                                                                      import {bootstrap} from '@angular/platform-browser/browser';
                                                                      import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig, RouteData} from
                                                                      'angular2/router';
                                                                      @Component({directives: [ROUTER_DIRECTIVES]})
                                                                      @RouteConfig([
                                                                      {path: '/user/:id', component: UserCmp, name: 'UserCmp', data: {isAdmin: true}},
                                                                      ])
                                                                      class AppCmp {}
                                                                      @Component({
                                                                      ...,
                                                                      template: 'user: {{isAdmin}}'
                                                                      })
                                                                      class UserCmp {
                                                                      string: isAdmin;
                                                                      constructor(data: RouteData) {
                                                                      this.isAdmin = data.get('isAdmin');
                                                                      }
                                                                      }
                                                                      bootstrap(AppCmp, ROUTER_PROVIDERS);

                                                                    constructor

                                                                    constructor(data?: { [key: string]: any });

                                                                      property data

                                                                      data: { [key: string]: any };

                                                                        method get

                                                                        get: (key: string) => any;

                                                                          class RouteParams

                                                                          class RouteParams {}
                                                                          • RouteParams is an immutable map of parameters for the given route based on the url matcher and optional parameters for that route.

                                                                            You can inject RouteParams into the constructor of a component to use it.

                                                                            ### Example

                                                                            import {Component} from '@angular/core';
                                                                            import {bootstrap} from '@angular/platform-browser/browser';
                                                                            import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig, RouteParams} from
                                                                            'angular2/router';
                                                                            @Component({directives: [ROUTER_DIRECTIVES]})
                                                                            @RouteConfig([
                                                                            {path: '/user/:id', component: UserCmp, name: 'UserCmp'},
                                                                            ])
                                                                            class AppCmp {}
                                                                            @Component({ template: 'user: {{id}}' })
                                                                            class UserCmp {
                                                                            id: string;
                                                                            constructor(params: RouteParams) {
                                                                            this.id = params.get('id');
                                                                            }
                                                                            }
                                                                            bootstrap(AppCmp, ROUTER_PROVIDERS);

                                                                          constructor

                                                                          constructor(params: { [key: string]: string });

                                                                            property params

                                                                            params: { [key: string]: string };

                                                                              method get

                                                                              get: (param: string) => string;

                                                                                class Router

                                                                                class Router {}
                                                                                • The Router is responsible for mapping URLs to components.

                                                                                  You can see the state of the router by inspecting the read-only field router.navigating. This may be useful for showing a spinner, for instance.

                                                                                  ## Concepts

                                                                                  Routers and component instances have a 1:1 correspondence.

                                                                                  The router holds reference to a number of RouterOutlet. An outlet is a placeholder that the router dynamically fills in depending on the current URL.

                                                                                  When the router navigates from a URL, it must first recognize it and serialize it into an Instruction. The router uses the RouteRegistry to get an Instruction.

                                                                                constructor

                                                                                constructor(
                                                                                registry: RouteRegistry,
                                                                                parent: Router,
                                                                                hostComponent: any,
                                                                                root?: Router
                                                                                );

                                                                                  property currentInstruction

                                                                                  currentInstruction: Instruction;
                                                                                  • The current Instruction for the router

                                                                                  property hostComponent

                                                                                  hostComponent: any;

                                                                                    property lastNavigationAttempt

                                                                                    lastNavigationAttempt: string;

                                                                                      property navigating

                                                                                      navigating: boolean;

                                                                                        property parent

                                                                                        parent: Router;

                                                                                          property registry

                                                                                          registry: RouteRegistry;

                                                                                            property root

                                                                                            root: Router;

                                                                                              method auxRouter

                                                                                              auxRouter: (hostComponent: any) => Router;
                                                                                              • Constructs a child router. You probably don't need to use this unless you're writing a reusable component.

                                                                                              method childRouter

                                                                                              childRouter: (hostComponent: any) => Router;
                                                                                              • Constructs a child router. You probably don't need to use this unless you're writing a reusable component.

                                                                                              method commit

                                                                                              commit: (
                                                                                              instruction: Instruction,
                                                                                              _skipLocationChange?: boolean
                                                                                              ) => Promise<any>;
                                                                                              • Updates this router and all descendant routers according to the given instruction

                                                                                              method config

                                                                                              config: (definitions: RouteDefinition[]) => Promise<any>;
                                                                                              • Dynamically update the routing configuration and trigger a navigation.

                                                                                                ### Usage

                                                                                                router.config([
                                                                                                { 'path': '/', 'component': IndexComp },
                                                                                                { 'path': '/user/:id', 'component': UserComp },
                                                                                                ]);

                                                                                              method deactivate

                                                                                              deactivate: (instruction: Instruction) => Promise<any>;
                                                                                              • Removes the contents of this router's outlet and all descendant outlets

                                                                                              method generate

                                                                                              generate: (linkParams: any[]) => Instruction;
                                                                                              • Generate an Instruction based on the provided Route Link DSL.

                                                                                              method isRouteActive

                                                                                              isRouteActive: (instruction: Instruction) => boolean;
                                                                                              • Given an instruction, returns true if the instruction is currently active, otherwise false.

                                                                                              method navigate

                                                                                              navigate: (linkParams: any[]) => Promise<any>;
                                                                                              • Navigate based on the provided Route Link DSL. It's preferred to navigate with this method over navigateByUrl.

                                                                                                ### Usage

                                                                                                This method takes an array representing the Route Link DSL:

                                                                                                ['./MyCmp', {param: 3}]

                                                                                                See the RouterLink directive for more.

                                                                                              method navigateByInstruction

                                                                                              navigateByInstruction: (
                                                                                              instruction: Instruction,
                                                                                              _skipLocationChange?: boolean
                                                                                              ) => Promise<any>;
                                                                                              • Navigate via the provided instruction. Returns a promise that resolves when navigation is complete.

                                                                                              method navigateByUrl

                                                                                              navigateByUrl: (url: string, _skipLocationChange?: boolean) => Promise<any>;
                                                                                              • Navigate to a URL. Returns a promise that resolves when navigation is complete. It's preferred to navigate with navigate instead of this method, since URLs are more brittle.

                                                                                                If the given URL begins with a /, router will navigate absolutely. If the given URL does not begin with /, the router will navigate relative to this component.

                                                                                              method recognize

                                                                                              recognize: (url: string) => Promise<Instruction>;
                                                                                              • Given a URL, returns an instruction representing the component graph

                                                                                              method registerAuxOutlet

                                                                                              registerAuxOutlet: (outlet: RouterOutlet) => Promise<any>;
                                                                                              • Register an outlet to notified of auxiliary route changes.

                                                                                                You probably don't need to use this unless you're writing a reusable component.

                                                                                              method registerPrimaryOutlet

                                                                                              registerPrimaryOutlet: (outlet: RouterOutlet) => Promise<any>;
                                                                                              • Register an outlet to be notified of primary route changes.

                                                                                                You probably don't need to use this unless you're writing a reusable component.

                                                                                              method renavigate

                                                                                              renavigate: () => Promise<any>;
                                                                                              • Navigates to either the last URL successfully navigated to, or the last URL requested if the router has yet to successfully navigate.

                                                                                              method subscribe

                                                                                              subscribe: (
                                                                                              onNext: (value: any) => void,
                                                                                              onError?: (value: any) => void
                                                                                              ) => Object;
                                                                                              • Subscribe to URL updates from the router

                                                                                              method unregisterPrimaryOutlet

                                                                                              unregisterPrimaryOutlet: (outlet: RouterOutlet) => void;
                                                                                              • Unregister an outlet (because it was destroyed, etc).

                                                                                                You probably don't need to use this unless you're writing a custom outlet implementation.

                                                                                              class RouteRegistry

                                                                                              class RouteRegistry {}
                                                                                              • The RouteRegistry holds route configurations for each component in an Angular app. It is responsible for creating Instructions from URLs, and generating URLs based on route and parameters.

                                                                                              constructor

                                                                                              constructor(_rootComponent: Type);

                                                                                                method config

                                                                                                config: (parentComponent: any, config: RouteDefinition) => void;
                                                                                                • Given a component and a configuration object, add the route to this registry

                                                                                                method configFromComponent

                                                                                                configFromComponent: (component: any) => void;
                                                                                                • Reads the annotations of a component and configures the registry based on them

                                                                                                method generate

                                                                                                generate: (
                                                                                                linkParams: any[],
                                                                                                ancestorInstructions: Instruction[],
                                                                                                _aux?: boolean
                                                                                                ) => Instruction;
                                                                                                • Given a normalized list with component names and params like: ['user', {id: 3 }] generates a url with a leading slash relative to the provided parentComponent.

                                                                                                  If the optional param _aux is true, then we generate starting at an auxiliary route boundary.

                                                                                                method generateDefault

                                                                                                generateDefault: (componentCursor: Type) => Instruction;

                                                                                                  method hasRoute

                                                                                                  hasRoute: (name: string, parentComponent: any) => boolean;

                                                                                                    method recognize

                                                                                                    recognize: (
                                                                                                    url: string,
                                                                                                    ancestorInstructions: Instruction[]
                                                                                                    ) => Promise<Instruction>;
                                                                                                    • Given a URL and a parent component, return the most specific instruction for navigating the application into the state specified by the url

                                                                                                    class RouterLink {}
                                                                                                    • The RouterLink directive lets you link to specific parts of your app.

                                                                                                      Consider the following route configuration:

                                                                                                      @RouteConfig([
                                                                                                      { path: '/user', component: UserCmp, name: 'User' }
                                                                                                      ]);
                                                                                                      class MyComp {}

                                                                                                      When linking to this User route, you can write:

                                                                                                      <a [routerLink]="['./User']">link to user component</a>

                                                                                                      RouterLink expects the value to be an array of route names, followed by the params for that level of routing. For instance ['/Team', {teamId: 1}, 'User', {userId: 2}] means that we want to generate a link for the Team route with params {teamId: 1}, and with a child route User with params {userId: 2}.

                                                                                                      The first route name should be prepended with /, ./, or ../. If the route begins with /, the router will look up the route from the root of the app. If the route begins with ./, the router will instead look in the current component's children for the route. And if the route begins with ../, the router will look at the current component's parent.

                                                                                                    constructor

                                                                                                    constructor(_router: Router, _location: Location);

                                                                                                      property isRouteActive

                                                                                                      isRouteActive: boolean;

                                                                                                        property routeParams

                                                                                                        routeParams: any[];

                                                                                                          property target

                                                                                                          target: string;

                                                                                                            property visibleHref

                                                                                                            visibleHref: string;

                                                                                                              method onClick

                                                                                                              onClick: () => boolean;

                                                                                                                class RouterOutlet

                                                                                                                class RouterOutlet implements OnDestroy {}
                                                                                                                • A router outlet is a placeholder that Angular dynamically fills based on the application's route.

                                                                                                                  ## Use

                                                                                                                  <router-outlet></router-outlet>

                                                                                                                constructor

                                                                                                                constructor(
                                                                                                                _viewContainerRef: ViewContainerRef,
                                                                                                                _loader: DynamicComponentLoader,
                                                                                                                _parentRouter: routerMod.Router,
                                                                                                                nameAttr: string
                                                                                                                );

                                                                                                                  property activateEvents

                                                                                                                  activateEvents: EventEmitter<any>;

                                                                                                                    property name

                                                                                                                    name: string;

                                                                                                                      method activate

                                                                                                                      activate: (nextInstruction: ComponentInstruction) => Promise<any>;
                                                                                                                      • Called by the Router to instantiate a new component during the commit phase of a navigation. This method in turn is responsible for calling the routerOnActivate hook of its child.

                                                                                                                      method deactivate

                                                                                                                      deactivate: (nextInstruction: ComponentInstruction) => Promise<any>;
                                                                                                                      • Called by the Router when an outlet disposes of a component's contents. This method in turn is responsible for calling the routerOnDeactivate hook of its child.

                                                                                                                      method ngOnDestroy

                                                                                                                      ngOnDestroy: () => void;

                                                                                                                        method reuse

                                                                                                                        reuse: (nextInstruction: ComponentInstruction) => Promise<any>;
                                                                                                                        • Called by the Router during the commit phase of a navigation when an outlet reuses a component between different routes. This method in turn is responsible for calling the routerOnReuse hook of its child.

                                                                                                                        method routerCanDeactivate

                                                                                                                        routerCanDeactivate: (nextInstruction: ComponentInstruction) => Promise<boolean>;
                                                                                                                        • Called by the Router during recognition phase of a navigation.

                                                                                                                          If this resolves to false, the given navigation is cancelled.

                                                                                                                          This method delegates to the child component's routerCanDeactivate hook if it exists, and otherwise resolves to true.

                                                                                                                        method routerCanReuse

                                                                                                                        routerCanReuse: (nextInstruction: ComponentInstruction) => Promise<boolean>;
                                                                                                                        • Called by the Router during recognition phase of a navigation.

                                                                                                                          If the new child component has a different Type than the existing child component, this will resolve to false. You can't reuse an old component when the new component is of a different Type.

                                                                                                                          Otherwise, this method delegates to the child component's routerCanReuse hook if it exists, or resolves to true if the hook is not present.

                                                                                                                        Interfaces

                                                                                                                        interface CanDeactivate

                                                                                                                        interface CanDeactivate {}
                                                                                                                        • Defines route lifecycle method routerCanDeactivate, which is called by the router to determine if a component can be removed as part of a navigation.

                                                                                                                          The routerCanDeactivate hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route.

                                                                                                                          If routerCanDeactivate returns or resolves to false, the navigation is cancelled. If it returns or resolves to true, then the navigation continues, and the component will be deactivated (the OnDeactivate hook will be run) and removed.

                                                                                                                          If routerCanDeactivate throws or rejects, the navigation is also cancelled.

                                                                                                                          ### Example

                                                                                                                        method routerCanDeactivate

                                                                                                                        routerCanDeactivate: (
                                                                                                                        nextInstruction: ComponentInstruction,
                                                                                                                        prevInstruction: ComponentInstruction
                                                                                                                        ) => boolean | Promise<boolean>;

                                                                                                                          interface CanReuse

                                                                                                                          interface CanReuse {}
                                                                                                                          • Defines route lifecycle method routerCanReuse, which is called by the router to determine whether a component should be reused across routes, or whether to destroy and instantiate a new component.

                                                                                                                            The routerCanReuse hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route.

                                                                                                                            If routerCanReuse returns or resolves to true, the component instance will be reused and the OnDeactivate hook will be run. If routerCanReuse returns or resolves to false, a new component will be instantiated, and the existing component will be deactivated and removed as part of the navigation.

                                                                                                                            If routerCanReuse throws or rejects, the navigation will be cancelled.

                                                                                                                            ### Example

                                                                                                                          method routerCanReuse

                                                                                                                          routerCanReuse: (
                                                                                                                          nextInstruction: ComponentInstruction,
                                                                                                                          prevInstruction: ComponentInstruction
                                                                                                                          ) => boolean | Promise<boolean>;

                                                                                                                            interface ComponentDefinition

                                                                                                                            interface ComponentDefinition {}
                                                                                                                            • Represents either a component type (type is component) or a loader function (type is loader).

                                                                                                                              See also RouteDefinition.

                                                                                                                            property component

                                                                                                                            component?: Type;

                                                                                                                              property loader

                                                                                                                              loader?: () => Promise<Type>;

                                                                                                                                property type

                                                                                                                                type: string;

                                                                                                                                  interface OnActivate

                                                                                                                                  interface OnActivate {}
                                                                                                                                  • Defines route lifecycle method routerOnActivate, which is called by the router at the end of a successful route navigation.

                                                                                                                                    For a single component's navigation, only one of either OnActivate or OnReuse will be called depending on the result of CanReuse.

                                                                                                                                    The routerOnActivate hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route or null.

                                                                                                                                    If routerOnActivate returns a promise, the route change will wait until the promise settles to instantiate and activate child components.

                                                                                                                                    ### Example

                                                                                                                                  method routerOnActivate

                                                                                                                                  routerOnActivate: (
                                                                                                                                  nextInstruction: ComponentInstruction,
                                                                                                                                  prevInstruction: ComponentInstruction
                                                                                                                                  ) => any | Promise<any>;

                                                                                                                                    interface OnDeactivate

                                                                                                                                    interface OnDeactivate {}
                                                                                                                                    • Defines route lifecycle method routerOnDeactivate, which is called by the router before destroying a component as part of a route change.

                                                                                                                                      The routerOnDeactivate hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route.

                                                                                                                                      If routerOnDeactivate returns a promise, the route change will wait until the promise settles.

                                                                                                                                      ### Example

                                                                                                                                    method routerOnDeactivate

                                                                                                                                    routerOnDeactivate: (
                                                                                                                                    nextInstruction: ComponentInstruction,
                                                                                                                                    prevInstruction: ComponentInstruction
                                                                                                                                    ) => any | Promise<any>;

                                                                                                                                      interface OnReuse

                                                                                                                                      interface OnReuse {}
                                                                                                                                      • Defines route lifecycle method routerOnReuse, which is called by the router at the end of a successful route navigation when CanReuse is implemented and returns or resolves to true.

                                                                                                                                        For a single component's navigation, only one of either OnActivate or OnReuse will be called, depending on the result of CanReuse.

                                                                                                                                        The routerOnReuse hook is called with two ComponentInstructions as parameters, the first representing the current route being navigated to, and the second parameter representing the previous route or null.

                                                                                                                                        ### Example

                                                                                                                                      method routerOnReuse

                                                                                                                                      routerOnReuse: (
                                                                                                                                      nextInstruction: ComponentInstruction,
                                                                                                                                      prevInstruction: ComponentInstruction
                                                                                                                                      ) => any | Promise<any>;

                                                                                                                                        interface RouteDefinition

                                                                                                                                        interface RouteDefinition {}
                                                                                                                                        • RouteDefinition defines a route within a RouteConfig decorator.

                                                                                                                                          Supported keys: - path or aux (requires exactly one of these) - component, loader, redirectTo (requires exactly one of these) - name (optional) - data (optional)

                                                                                                                                          See also Route, AsyncRoute, AuxRoute, and Redirect.

                                                                                                                                        property aux

                                                                                                                                        aux?: string;

                                                                                                                                          property component

                                                                                                                                          component?: Type | ComponentDefinition;

                                                                                                                                            property data

                                                                                                                                            data?: any;

                                                                                                                                              property loader

                                                                                                                                              loader?: () => Promise<Type>;

                                                                                                                                                property name

                                                                                                                                                name?: string;

                                                                                                                                                  property path

                                                                                                                                                  path?: string;

                                                                                                                                                    property redirectTo

                                                                                                                                                    redirectTo?: any[];

                                                                                                                                                      property regex

                                                                                                                                                      regex?: string;

                                                                                                                                                        property regex_group_names

                                                                                                                                                        regex_group_names?: string[];

                                                                                                                                                          property serializer

                                                                                                                                                          serializer?: RegexSerializer;

                                                                                                                                                            property useAsDefault

                                                                                                                                                            useAsDefault?: boolean;

                                                                                                                                                              Package Files (14)

                                                                                                                                                              Dependencies (0)

                                                                                                                                                              No dependencies.

                                                                                                                                                              Dev Dependencies (0)

                                                                                                                                                              No dev dependencies.

                                                                                                                                                              Peer Dependencies (3)

                                                                                                                                                              Badge

                                                                                                                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@angular/router-deprecated.

                                                                                                                                                              • Markdown
                                                                                                                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@angular/router-deprecated)
                                                                                                                                                              • HTML
                                                                                                                                                                <a href="https://www.jsdocs.io/package/@angular/router-deprecated"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>