aurelia-router
- Version 1.7.1
- Published
- 1.02 MB
- 6 dependencies
- MIT license
Install
npm i aurelia-router
yarn add aurelia-router
pnpm add aurelia-router
Overview
A powerful client-side router.
Index
Variables
Functions
Classes
Router
- addRoute()
- baseUrl
- configure()
- container
- couldDeactivate
- createChild()
- createNavModel()
- currentInstruction
- currentNavigationTracker
- ensureConfigured()
- generate()
- handleUnknownRoutes()
- hasOwnRoute()
- hasRoute()
- history
- isConfigured
- isExplicitNavigation
- isExplicitNavigationBack
- isNavigating
- isNavigatingBack
- isNavigatingFirst
- isNavigatingForward
- isNavigatingNew
- isNavigatingRefresh
- isRoot
- navigate()
- navigateBack()
- navigateToRoute()
- navigation
- options
- parent
- refreshNavigation()
- registerViewPort()
- reset()
- routes
- title
- titleSeparator
- transformTitle
- updateTitle()
- useViewPortDefaults()
- viewPortDefaults
- viewPorts
Interfaces
Enums
Type Aliases
Variables
variable activationStrategy
const activationStrategy: ActivationStrategy;
The strategy to use when activating modules during navigation.
Functions
function isNavigationCommand
isNavigationCommand: (obj: any) => obj is NavigationCommand;
Determines if the provided object is a navigation command. A navigation command is anything with a navigate method.
Parameter obj
The object to check.
Classes
class ActivateNextStep
class ActivateNextStep {}
A pipeline step responsible for finding and activating method
activate
on a view model of a route
method run
run: (navigationInstruction: NavigationInstruction, next: Next) => Promise<any>;
class AppRouter
class AppRouter extends Router {}
The main application router.
constructor
constructor( container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator);
property events
events: EventAggregator;
method activate
activate: (options?: NavigationOptions) => void;
Activates the router. This instructs the router to begin listening for history changes and processing instructions.
options The set of options to activate the router with.
method deactivate
deactivate: () => void;
Deactivates the router.
method loadUrl
loadUrl: (url: string) => Promise<NavigationInstruction>;
Loads the specified URL.
Parameter url
The URL fragment to load.
method registerViewPort
registerViewPort: (viewPort: any, name?: string) => Promise<any>;
Registers a viewPort to be used as a rendering target for activated routes.
Parameter viewPort
The viewPort. This is typically a element in Aurelia default impl
Parameter name
The name of the viewPort. 'default' if unspecified.
method reset
reset: () => void;
Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made. Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.
class BuildNavigationPlanStep
class BuildNavigationPlanStep {}
Transform a navigation instruction into viewport plan record object, or a redirect request if user viewmodel demands
method run
run: (navigationInstruction: NavigationInstruction, next: Next) => Promise<any>;
class CanActivateNextStep
class CanActivateNextStep {}
A pipeline step responsible for finding and activating method
canActivate
on a view model of a route
method run
run: (navigationInstruction: NavigationInstruction, next: Next) => Promise<any>;
class CanDeactivatePreviousStep
class CanDeactivatePreviousStep {}
A pipeline step responsible for finding and activating method
canDeactivate
on a view model of a route
method run
run: (navigationInstruction: NavigationInstruction, next: Next) => Promise<any>;
class CommitChangesStep
class CommitChangesStep {}
A pipeline step for instructing a piepline to commit changes on a navigation instruction
method run
run: ( navigationInstruction: NavigationInstruction, next: Function) => Promise<any>;
class DeactivatePreviousStep
class DeactivatePreviousStep {}
A pipeline step responsible for finding and activating method
deactivate
on a view model of a route
method run
run: (navigationInstruction: NavigationInstruction, next: Next) => Promise<any>;
class LoadRouteStep
class LoadRouteStep {}
A pipeline step responsible for loading a route config of a navigation instruction
constructor
constructor(routeLoader: RouteLoader);
method run
run: (navigationInstruction: NavigationInstruction, next: Next) => Promise<any>;
Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline
class NavigationInstruction
class NavigationInstruction {}
Class used to represent an instruction during a navigation.
constructor
constructor(init: NavigationInstructionInit);
property config
config: RouteConfig;
The route config for the route matching this instruction.
property fragment
fragment: string;
The URL fragment.
property options
options: Record<string, any>;
property params
params: any;
Parameters extracted from the route pattern.
property parentCatchHandler
parentCatchHandler: any;
property parentInstruction
parentInstruction: NavigationInstruction;
The parent instruction, if this instruction was created by a child router.
property plan
plan: Record<string, any>;
Current built viewport plan of this nav instruction
property previousInstruction
previousInstruction: NavigationInstruction;
The instruction being replaced by this instruction in the current router.
property queryParams
queryParams: any;
Parameters extracted from the query string.
property queryString
queryString: string;
The query string.
property router
router: Router;
The router instance.
property viewPortInstructions
viewPortInstructions: Record<string, any>;
viewPort instructions to used activation.
method addViewPortInstruction
addViewPortInstruction: { (initOptions: ViewPortInstructionInit): any; ( viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any ): any;};
Adds a viewPort instruction. Returns the newly created instruction based on parameters
method getAllInstructions
getAllInstructions: () => Array<NavigationInstruction>;
Gets an array containing this instruction and all child instructions for the current navigation.
method getAllPreviousInstructions
getAllPreviousInstructions: () => Array<NavigationInstruction>;
Gets an array containing the instruction and all child instructions for the previous navigation. Previous instructions are no longer available after navigation completes.
method getBaseUrl
getBaseUrl: () => string;
Gets the instruction's base URL, accounting for wildcard route parameters.
method getWildCardName
getWildCardName: () => string;
Gets the name of the route pattern's wildcard parameter, if applicable.
method getWildcardPath
getWildcardPath: () => string;
Gets the path and query string created by filling the route pattern's wildcard parameter with the matching param.
class NavModel
class NavModel {}
Class for storing and interacting with a route's navigation settings.
constructor
constructor(router: Router, relativeHref: string);
property config
config: RouteConfig;
The route config.
property href
href: string;
This nav item's absolute href.
property isActive
isActive: boolean;
True if this nav item is currently active.
property order
order: number | boolean;
property relativeHref
relativeHref: string;
This nav item's relative href.
property router
router: Router;
The router associated with this navigation model.
property settings
settings: any;
Data attached to the route at configuration time.
property title
title: string;
The title.
method setTitle
setTitle: (title: string) => void;
Sets the route's title and updates document.title. If the a navigation is in progress, the change will be applied to document.title when the navigation completes.
Parameter title
The new title.
class Pipeline
class Pipeline {}
The class responsible for managing and processing the navigation pipeline.
property steps
steps: StepRunnerFunction[];
The pipeline steps. And steps added via addStep will be converted to a function The actualy running functions with correct step contexts of this pipeline
method addStep
addStep: (step: StepRunnerFunction | PipelineStep | IPipelineSlot) => Pipeline;
Adds a step to the pipeline.
Parameter step
The pipeline step.
method run
run: (instruction: NavigationInstruction) => Promise<PipelineResult>;
Runs the pipeline.
Parameter instruction
The navigation instruction to process.
class PipelineProvider
class PipelineProvider {}
Class responsible for creating the navigation pipeline.
constructor
constructor(container: Container);
method addStep
addStep: (name: string, step: PipelineStep | Function) => void;
Adds a step into the pipeline at a known slot location.
method createPipeline
createPipeline: (useCanDeactivateStep?: boolean) => Pipeline;
Create the navigation pipeline.
method removeStep
removeStep: (name: string, step: PipelineStep) => void;
Removes a step from a slot in the pipeline
method reset
reset: () => void;
Resets all pipeline slots
class Redirect
class Redirect implements NavigationCommand {}
Used during the activation lifecycle to cause a redirect.
constructor
constructor(url: string, options?: NavigationOptions);
Parameter url
The URL fragment to use as the navigation destination.
Parameter options
The navigation options.
property url
url: string;
method navigate
navigate: (appRouter: Router) => void;
Called by the navigation pipeline to navigate.
Parameter appRouter
The router to be redirected.
method setRouter
setRouter: (router: Router) => void;
Called by the activation system to set the child router.
Parameter router
The router.
class RedirectToRoute
class RedirectToRoute implements NavigationCommand {}
Used during the activation lifecycle to cause a redirect to a named route.
constructor
constructor(route: string, params?: any, options?: NavigationOptions);
Parameter route
The name of the route.
Parameter params
The parameters to be sent to the activation method.
Parameter options
The options to use for navigation.
property params
params: any;
property route
route: string;
method navigate
navigate: (appRouter: Router) => void;
Called by the navigation pipeline to navigate.
Parameter appRouter
The router to be redirected.
method setRouter
setRouter: (router: Router) => void;
Called by the activation system to set the child router.
Parameter router
The router.
class RouteLoader
class RouteLoader {}
Abstract class that is responsible for loading view / view model from a route config The default implementation can be found in
aurelia-templating-router
method loadRoute
loadRoute: ( router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction) => Promise<any>;
Load a route config based on its viewmodel / view configuration
class Router
class Router {}
The primary class responsible for handling routing and navigation.
constructor
constructor(container: Container, history: History);
Parameter container
The [[Container]] to use when child routers.
Parameter history
The [[History]] implementation to delegate navigation requests to.
property baseUrl
baseUrl: string;
The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].
property container
container: Container;
Container associated with this router. Also used to create child container for creating child router.
property couldDeactivate
couldDeactivate: boolean;
True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.
property currentInstruction
currentInstruction: NavigationInstruction;
The currently active navigation instruction.
property currentNavigationTracker
currentNavigationTracker: number;
The currently active navigation tracker.
property history
history: History;
History instance of Aurelia abstract class for wrapping platform history global object
property isConfigured
isConfigured: boolean;
True if the [[Router]] has been configured.
property isExplicitNavigation
isExplicitNavigation: boolean;
True if the [[Router]] is navigating due to explicit call to navigate function(s).
property isExplicitNavigationBack
isExplicitNavigationBack: boolean;
True if the [[Router]] is navigating due to explicit call to navigateBack function.
property isNavigating
isNavigating: boolean;
True if the [[Router]] is currently processing a navigation.
property isNavigatingBack
isNavigatingBack: boolean;
True if the [[Router]] is navigating back in the browser session history.
property isNavigatingFirst
isNavigatingFirst: boolean;
True if the [[Router]] is navigating into the app for the first time in the browser session.
property isNavigatingForward
isNavigatingForward: boolean;
True if the [[Router]] is navigating forward in the browser session history.
property isNavigatingNew
isNavigatingNew: boolean;
True if the [[Router]] is navigating to a page instance not in the browser session history.
property isNavigatingRefresh
isNavigatingRefresh: boolean;
True if the [[Router]] is navigating due to a browser refresh.
property isRoot
readonly isRoot: boolean;
Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.
property navigation
navigation: NavModel[];
The navigation models for routes that specified [[RouteConfig.nav]].
property options
options: any;
property parent
parent: Router;
The parent router, or null if this instance is not a child router.
property routes
routes: RouteConfig[];
List of route configs registered with this router
property title
title: string;
If defined, used in generation of document title for [[Router]]'s routes.
property titleSeparator
titleSeparator: string;
The separator used in the document title between [[Router]]'s routes.
property transformTitle
transformTitle: (title: string) => string;
Extension point to transform the document title before it is built and displayed. By default, child routers delegate to the parent router, and the app router returns the title unchanged.
property viewPortDefaults
viewPortDefaults: Record<string, any>;
The defaults used when a viewport lacks specified content
property viewPorts
viewPorts: Record<string, any>;
A registry of registered viewport. Will be used to handle process navigation instruction route loading and dom swapping
method addRoute
addRoute: (config: RouteConfig, navModel?: NavModel) => void;
Registers a new route with the router.
Parameter config
The [[RouteConfig]].
Parameter navModel
The [[NavModel]] to use for the route. May be omitted for single-pattern routes.
method configure
configure: ( callbackOrConfig: | RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)) => Promise<void>;
Configures the router.
Parameter callbackOrConfig
The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].
method createChild
createChild: (container?: Container) => Router;
Creates a child router of the current router.
Parameter container
The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.
Returns
{Router} The new child Router.
method createNavModel
createNavModel: (config: RouteConfig) => NavModel;
Creates a [[NavModel]] for the specified route config.
Parameter config
The route config.
method ensureConfigured
ensureConfigured: () => Promise<void>;
Returns a Promise that resolves when the router is configured.
method generate
generate: ( nameOrRoute: string | RouteConfig, params?: any, options?: any) => string;
Generates a URL fragment matching the specified route pattern.
Parameter name
The name of the route whose pattern should be used to generate the fragment.
Parameter params
The route params to be used to populate the route pattern.
Parameter options
If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.
Returns
{string} A string containing the generated URL fragment.
method handleUnknownRoutes
handleUnknownRoutes: (config?: RouteConfigSpecifier) => void;
Register a handler to use when the incoming URL fragment doesn't match any registered routes.
Parameter config
The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].
method hasOwnRoute
hasOwnRoute: (name: string) => boolean;
Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.
Parameter name
The name of the route to check.
method hasRoute
hasRoute: (name: string) => boolean;
Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.
Parameter name
The name of the route to check.
method navigate
navigate: (fragment: string, options?: NavigationOptions) => boolean;
Navigates to a new location.
Parameter fragment
The URL fragment to use as the navigation destination.
Parameter options
The navigation options.
method navigateBack
navigateBack: () => void;
Navigates back to the most recent location in history.
method navigateToRoute
navigateToRoute: ( route: string, params?: any, options?: NavigationOptions) => boolean;
Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed by [[Router.navigate]].
Parameter route
The name of the route to use when generating the navigation location.
Parameter params
The route parameters to be used when populating the route pattern.
Parameter options
The navigation options.
method refreshNavigation
refreshNavigation: () => void;
Updates the navigation routes with hrefs relative to the current location. Note: This method will likely move to a plugin in a future release.
method registerViewPort
registerViewPort: (viewPort: any, name?: string) => void;
Registers a viewPort to be used as a rendering target for activated routes.
Parameter viewPort
The viewPort.
Parameter name
The name of the viewPort. 'default' if unspecified.
method reset
reset: () => void;
Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made. Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.
method updateTitle
updateTitle: () => void;
Updates the document title using the current navigation instruction.
method useViewPortDefaults
useViewPortDefaults: ($viewPortDefaults: Record<string, any>) => void;
Sets the default configuration for the view ports. This specifies how to populate a view port for which no module is specified. The default is an empty view/view-model pair.
class RouterConfiguration
class RouterConfiguration {}
Class used to configure a [[Router]] instance.
property instructions
instructions: ((router: Router) => void)[];
property options
options: { [key: string]: any; compareQueryParams?: boolean; root?: string; pushState?: boolean; hashChange?: boolean; silent?: boolean;};
property pipelineSteps
pipelineSteps: { name: string; step: Function | PipelineStep }[];
property title
title: string;
property titleSeparator
titleSeparator: string;
property unknownRouteConfig
unknownRouteConfig: RouteConfigSpecifier;
property viewPortDefaults
viewPortDefaults: Record<string, any>;
method addAuthorizeStep
addAuthorizeStep: (step: Function | PipelineStep) => RouterConfiguration;
Adds a step to be run during the [[Router]]'s authorize pipeline slot.
Parameter step
The pipeline step.
method addPipelineStep
addPipelineStep: ( name: string, step: Function | PipelineStep) => RouterConfiguration;
Adds a step to be run during the [[Router]]'s navigation pipeline.
Parameter name
The name of the pipeline slot to insert the step into.
Parameter step
The pipeline step.
method addPostRenderStep
addPostRenderStep: (step: Function | PipelineStep) => RouterConfiguration;
Adds a step to be run during the [[Router]]'s postRender pipeline slot.
Parameter step
The pipeline step.
method addPreActivateStep
addPreActivateStep: (step: Function | PipelineStep) => RouterConfiguration;
Adds a step to be run during the [[Router]]'s preActivate pipeline slot.
Parameter step
The pipeline step.
method addPreRenderStep
addPreRenderStep: (step: Function | PipelineStep) => RouterConfiguration;
Adds a step to be run during the [[Router]]'s preRender pipeline slot.
Parameter step
The pipeline step.
method exportToRouter
exportToRouter: (router: Router) => void;
Applies the current configuration to the specified [[Router]].
Parameter router
The [[Router]] to apply the configuration to.
method fallbackRoute
fallbackRoute: (fragment: string) => RouterConfiguration;
Configures a route that will be used if there is no previous location available on navigation cancellation.
Parameter fragment
The URL fragment to use as the navigation destination.
method map
map: (route: RouteConfig | RouteConfig[]) => RouterConfiguration;
Maps one or more routes to be registered with the router.
Parameter route
The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.
method mapRoute
mapRoute: (config: RouteConfig) => RouterConfiguration;
Maps a single route to be registered with the router.
Parameter route
The [[RouteConfig]] to map.
method mapUnknownRoutes
mapUnknownRoutes: (config: RouteConfigSpecifier) => RouterConfiguration;
Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.
Parameter config
A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the [[NavigationInstruction]] and selects a moduleId to load.
method useViewPortDefaults
useViewPortDefaults: ( viewPortConfig: Record<string, { [key: string]: any; moduleId: string }>) => RouterConfiguration;
Configures defaults to use for any view ports.
Parameter viewPortConfig
a view port configuration object to use as a default, of the form { viewPortName: { moduleId } }.
Interfaces
interface ActivationStrategy
interface ActivationStrategy {}
An optional interface describing the available activation strategies.
property invokeLifecycle
invokeLifecycle: 'invoke-lifecycle';
Reuse the existing view model, invoking Router lifecycle hooks.
property noChange
noChange: 'no-change';
Reuse the existing view model, without invoking Router lifecycle hooks.
property replace
replace: 'replace';
Replace the existing view model, invoking Router lifecycle hooks.
interface ConfiguresRouter
interface ConfiguresRouter {}
An optional interface describing the router configuration convention.
method configureRouter
configureRouter: ( config: RouterConfiguration, router: Router) => Promise<void> | PromiseLike<void> | void;
Implement this hook if you want to configure a router.
interface IObservable
interface IObservable {}
A basic interface for an Observable type
method subscribe
subscribe: (sub?: IObservableConfig) => ISubscription;
interface IObservableConfig
interface IObservableConfig {}
interface IPipelineSlot
interface IPipelineSlot {}
A multi-step pipeline step that helps enable multiple hooks to the pipeline
interface ISubscription
interface ISubscription {}
A basic interface for a Subscription to an Observable
method unsubscribe
unsubscribe: () => void;
interface NavigationCommand
interface NavigationCommand {}
When a navigation command is encountered, the current navigation will be cancelled and control will be passed to the navigation command so it can determine the correct action.
property navigate
navigate: (router: Router) => void;
interface NavigationInstructionInit
interface NavigationInstructionInit {}
Initialization options for a navigation instruction
property config
config: RouteConfig;
property fragment
fragment: string;
property options
options?: Object;
property params
params?: Record<string, any>;
property parentInstruction
parentInstruction?: NavigationInstruction;
property plan
plan?: Record<string, /*ViewPortInstruction*/ any>;
property previousInstruction
previousInstruction?: NavigationInstruction;
property queryParams
queryParams?: Record<string, any>;
property queryString
queryString?: string;
property router
router: Router;
interface Next
interface Next<T = any> {}
A callback to indicate when pipeline processing should advance to the next step or be aborted.
property cancel
cancel: NextCompletionHandler<T>;
Indicates that the pipeline should cancel processing.
property complete
complete: NextCompletionHandler<T>;
Indicates the successful completion of the entire pipeline.
property reject
reject: NextCompletionHandler<T>;
Indicates that pipeline processing has failed and should be stopped.
call signature
(): Promise<any>;
Indicates the successful completion of the pipeline step.
interface NextCompletionResult
interface NextCompletionResult<T = any> {}
Next Completion result. Comprises of final status, output (could be value/error) and flag
completed
interface PipelineResult
interface PipelineResult {}
The result of a pipeline run.
property completed
completed: boolean;
property instruction
instruction: NavigationInstruction;
property output
output: any;
property status
status: string;
interface PipelineStep
interface PipelineStep {}
A step to be run during processing of the pipeline.
method run
run: (instruction: NavigationInstruction, next: Next) => Promise<any>;
Execute the pipeline step. The step should invoke next(), next.complete(), next.cancel(), or next.reject() to allow the pipeline to continue.
Parameter instruction
The navigation instruction.
Parameter next
The next step in the pipeline.
interface RedirectConfig
interface RedirectConfig {}
A configuration object that describes a route for redirection
property redirect
redirect: string;
path that will be redirected to. This is relative to currently in process router
index signature
[key: string]: any;
A backward compat interface. Should be ignored in new code
interface RoutableComponentActivate
interface RoutableComponentActivate {}
An optional interface describing the activate convention.
method activate
activate: ( params: any, routeConfig: RouteConfig, navigationInstruction: NavigationInstruction) => Promise<void> | PromiseLike<void> | IObservable | void;
Implement this hook if you want to perform custom logic just before your view-model is displayed. You can optionally return a promise to tell the router to wait to bind and attach the view until after you finish your work.
interface RoutableComponentCanActivate
interface RoutableComponentCanActivate {}
An optional interface describing the canActivate convention.
method canActivate
canActivate: ( params: any, routeConfig: RouteConfig, navigationInstruction: NavigationInstruction) => | boolean | Promise<boolean> | PromiseLike<boolean> | NavigationCommand | Promise<NavigationCommand> | PromiseLike<NavigationCommand>;
Implement this hook if you want to control whether or not your view-model can be navigated to. Return a boolean value, a promise for a boolean value, or a navigation command.
interface RoutableComponentCanDeactivate
interface RoutableComponentCanDeactivate {}
An optional interface describing the canDeactivate convention.
property canDeactivate
canDeactivate: () => | boolean | Promise<boolean> | PromiseLike<boolean> | NavigationCommand;
Implement this hook if you want to control whether or not the router can navigate away from your view-model when moving to a new route. Return a boolean value, a promise for a boolean value, or a navigation command.
interface RoutableComponentDeactivate
interface RoutableComponentDeactivate {}
An optional interface describing the deactivate convention.
property deactivate
deactivate: () => Promise<void> | PromiseLike<void> | IObservable | void;
Implement this hook if you want to perform custom logic when your view-model is being navigated away from. You can optionally return a promise to tell the router to wait until after you finish your work.
interface RoutableComponentDetermineActivationStrategy
interface RoutableComponentDetermineActivationStrategy {}
An optional interface describing the determineActivationStrategy convention.
method determineActivationStrategy
determineActivationStrategy: ( params: any, routeConfig: RouteConfig, navigationInstruction: NavigationInstruction) => ActivationStrategyType;
Implement this hook if you want to give hints to the router about the activation strategy, when reusing a view model for different routes. Available values are 'replace' and 'invoke-lifecycle'.
interface RouteConfig
interface RouteConfig {}
A configuration object that describes a route.
property activationStrategy
activationStrategy?: ActivationStrategyType;
Add to specify an activation strategy if it is always the same and you do not want that to be in your view-model code. Available values are 'replace' and 'invoke-lifecycle'.
property caseSensitive
caseSensitive?: boolean;
When true is specified, this route will be case sensitive.
property generationUsesHref
generationUsesHref?: boolean;
Indicates that when route generation is done for this route, it should just take the literal value of the href property.
property href
href?: string;
The URL fragment to use in nav models. If unspecified, the [[RouteConfig.route]] will be used. However, if the [[RouteConfig.route]] contains dynamic segments, this property must be specified.
property layoutModel
layoutModel?: any;
specifies the model parameter to pass to the layout view model's
activate
function.
property layoutView
layoutView?: string;
specifies the file name of a layout view to use.
property layoutViewModel
layoutViewModel?: string;
specifies the moduleId of the view model to use with the layout view.
property moduleId
moduleId?: string;
The moduleId of the view model that should be activated for this route.
property name
name?: string;
A unique name for the route that may be used to identify the route when generating URL fragments. Required when this route should support URL generation, such as with [[Router.generate]] or the route-href custom attribute.
property nav
nav?: boolean | number;
When specified, this route will be included in the [[Router.navigation]] nav model. Useful for dynamically generating menus or other navigation elements. When a number is specified, that value will be used as a sort order.
property navigationStrategy
navigationStrategy?: ( instruction: NavigationInstruction) => Promise<void> | void;
A function that can be used to dynamically select the module or modules to activate. The function is passed the current [[NavigationInstruction]], and should configure instruction.config with the desired moduleId, viewPorts, or redirect.
property navModel
navModel?: NavModel;
The navigation model for storing and interacting with the route's navigation settings.
property redirect
redirect?: string;
A URL fragment to redirect to when this route is matched.
property route
route: string | string[];
The route pattern to match against incoming URL fragments, or an array of patterns.
property settings
settings?: any;
Arbitrary data to attach to the route. This can be used to attached custom data needed by components like pipeline steps and activated modules.
property title
title?: string;
The document title to set when this route is active.
property viewPorts
viewPorts?: any;
The view ports to target when activating this route. If unspecified, the target moduleId is loaded into the default viewPort (the viewPort with name 'default'). The viewPorts object should have keys whose property names correspond to names used by elements. The values should be objects specifying the moduleId to load into that viewPort. The values may optionally include properties related to layout:
layoutView
,layoutViewModel
andlayoutModel
.
index signature
[x: string]: any;
interface ViewPortComponent
interface ViewPortComponent {}
The component responsible for routing
property childContainer
childContainer?: Container;
property childRouter
childRouter?: Router;
property config
config?: RouteConfig;
property router
router: Router;
property viewModel
viewModel: any;
index signature
[key: string]: any;
This is for backward compat, when moving from any to a more strongly typed interface
interface ViewPortInstructionInit
interface ViewPortInstructionInit {}
Enums
enum PipelineSlotName
const enum PipelineSlotName { Authorize = 'authorize', PreActivate = 'preActivate', PreRender = 'preRender', PostRender = 'postRender',}
Available pipeline slot names to insert interceptor into router pipeline
member Authorize
Authorize = 'authorize'
Authorization slot. Invoked early in the pipeline, before
canActivate
hook of incoming route
member PostRender
PostRender = 'postRender'
Post-render slot. Invoked last in the pipeline
member PreActivate
PreActivate = 'preActivate'
Pre-activation slot. Invoked early in the pipeline, Invoked timing: - after Authorization slot - after canActivate hook on new view model - before deactivate hook on old view model - before activate hook on new view model
member PreRender
PreRender = 'preRender'
Pre-render slot. Invoked later in the pipeline Invokcation timing: - after activate hook on new view model - before commit step on new navigation instruction
enum PipelineStatus
const enum PipelineStatus { Completed = 'completed', Canceled = 'canceled', Rejected = 'rejected', Running = 'running',}
The status of a Pipeline.
enum RouterEvent
const enum RouterEvent { Processing = 'router:navigation:processing', Error = 'router:navigation:error', Canceled = 'router:navigation:canceled', Complete = 'router:navigation:complete', Success = 'router:navigation:success', ChildComplete = 'router:navigation:child:complete',}
A list of known router events used by the Aurelia router to signal the pipeline has come to a certain state
member Canceled
Canceled = 'router:navigation:canceled'
member ChildComplete
ChildComplete = 'router:navigation:child:complete'
member Complete
Complete = 'router:navigation:complete'
member Error
Error = 'router:navigation:error'
member Processing
Processing = 'router:navigation:processing'
member Success
Success = 'router:navigation:success'
Type Aliases
type ActivationStrategyType
type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];
Enum like type for activation strategy built-in values
type NavigationResult
type NavigationResult = boolean | Promise<PipelineResult | boolean>;
type NextCompletionHandler
type NextCompletionHandler<T = any> = ( output?: T) => Promise<NextCompletionResult<T>>;
Handler for resolving
NextCompletionResult
type RouteConfigSpecifier
type RouteConfigSpecifier = | string | RouteOrRedirectConfig | (( instruction: NavigationInstruction ) => string | RouteOrRedirectConfig | Promise<string | RouteOrRedirectConfig>);
A RouteConfig specifier. Could be a string, or an object with
RouteConfig
interface shape, or could be an object with redirect interface shape
type RouteOrRedirectConfig
type RouteOrRedirectConfig = RouteConfig | RedirectConfig;
A more generic RouteConfig for unknown route. Either a redirect config or a
RouteConfig
Redirect config is generally used inmapUnknownRoutes
ofRouterConfiguration
type StepRunnerFunction
type StepRunnerFunction = <TThis = any>( this: TThis, instruction: NavigationInstruction, next: Next) => any;
Package Files (1)
Dependencies (6)
Dev Dependencies (24)
- @types/jasmine
- aurelia-framework
- aurelia-pal-browser
- aurelia-polyfills
- aurelia-tools
- dts-bundle-generator
- gulp-watch
- jasmine-core
- karma
- karma-chrome-launcher
- karma-jasmine
- karma-mocha-reporter
- karma-sourcemap-loader
- karma-webpack
- rimraf
- rollup
- rollup-plugin-typescript2
- standard-version
- ts-loader
- tslib
- tslint
- typescript
- webpack
- yargs
Peer Dependencies (1)
Badge
To add a badge like this oneto 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/aurelia-router
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/aurelia-router)
- HTML<a href="https://www.jsdocs.io/package/aurelia-router"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4615 ms. - Missing or incorrect documentation? Open an issue for this package.