Dynamic module plugins/router

Index

Variables

Interfaces

Variables

activate: (defaultRoute: string) => JQueryPromise<any>

After you've configured the router, you need to activate it. This is usually done in your shell. The activate function of the router returns a promise that resolves when the router is ready to start. To use the router, you should add an activate function to your shell and return the result from that. The application startup infrastructure of Durandal will detect your shell's activate function and call it at the appropriate time, waiting for it's promise to resolve. This allows Durandal to properly orchestrate the timing of composition and databinding along with animations and splash screen display.

activeItem: IDurandalViewModelActiveItem

An observable whose value is the currently active item/module/page.

activeRoute: KnockoutObservable

An observable whose value is the currently active route.

afterCompose: () => void

called after an a new module is composed

allRoutes: KnockoutObservableArray

An observable array containing all route info objects.

autoConvertRouteToModuleId: (url: string) => string

This can be overwritten to provide your own convention for automatically converting routes to module ids.

convertRouteToModuleId: (url: string) => string

Takes a route in and returns a calculated moduleId. Simple transformations of this can be done via the useConvention function above. For more advanced transformations, you can override this function.

convertRouteToName: (route: string) => string

akes a route in and returns a calculated name.

getActivatableInstance: (routeInfo: "durandal/plugins/router".IRouteInfo, params: any, module: any) => any

Returns the activatable instance from the supplied module.

guardRoute: (routeInfo: "durandal/plugins/router".IRouteInfo, params: any, instance: any) => any

Before any route is activated, the guardRoute funtion is called. You can plug into this function to add custom logic to allow, deny or redirect based on the requested route. To allow, return true. To deny, return false. To redirect, return a string with the hash or url. You may also return a promise for any of these values.

handleInvalidRoute: (route: "durandal/plugins/router".IRouteInfo, parameters: any) => void

This should not normally be overwritten. But advanced users can override this to completely transform the developer's routeInfo input into the final version used to configure the router.

isNavigating: KnockoutObservable

An observable boolean which is true while navigation is in process; false otherwise.

map: { (routeOrRouteArray: "durandal/plugins/router".IRouteInfoParameters): "durandal/plugins/router".IRouteInfo; (routeOrRouteArray: "durandal/plugins/router".IRouteInfoParameters[]): "durandal/plugins/router".IRouteInfo[]; }

This function takes an array of routeInfo objects or a single routeInfo object and uses it to configure the router. The finalized routeInfo (or array of infos) is returned.

(): IRouteInfo

Returns

IRouteInfo

(): IRouteInfo[]

Returns

IRouteInfo[]

mapAuto: (path?: string) => void

Once the router is required, you can call router.mapAuto(). This is the most basic configuration option. When you call this function (with no parameters) it tells the router to directly correlate route parameters to module names in the viewmodels folder.

mapNav: (url: string, moduleId?: string, name?: string) => "durandal/plugins/router".IRouteInfo

Works the same as mapRoute except that routes are automatically added to the visibleRoutes array.

mapRoute: { (route: "durandal/plugins/router".IRouteInfoParameters): "durandal/plugins/router".IRouteInfo; (url: string, moduleId?: string, name?: string, visible?: boolean): "durandal/plugins/router".IRouteInfo; }

You can pass a single routeInfo to this function, or you can pass the basic configuration parameters. url is your url pattern, moduleId is the module path this pattern will map to, name is used as the document title and visible determines whether or not to include it in the router's visibleRoutes array for easy navigation UI binding.

(): IRouteInfo

Returns

IRouteInfo

(): IRouteInfo

Returns

IRouteInfo

navigateBack: () => void

Causes the router to move backwards in page history.

navigateTo: (url: string) => void

Causes the router to navigate to a specific url.

prepareRouteInfo: (info: "durandal/plugins/router".IRouteInfo) => void

This should not normally be overwritten. But advanced users can override this to completely transform the developer's routeInfo input into the final version used to configure the router.

ready: KnockoutObservable

observable that is called when the router is ready

replaceLocation: (url: string) => void

replaces the windows.location w/ the url

useConvention: () => void

Use router default convention.

visibleRoutes: KnockoutObservableArray

An observable array containing route info objects configured with visible:true (or by calling the mapNav function).