Skip to content

ui-router-navigation-location-plugin / NavigationLocationService

Class: NavigationLocationService ​

Defined in: index.ts:146

Location service implementation using the Navigation API.

Uses the browser's Navigation API for URL management instead of the History API, providing better integration with browser navigation.

The service intercepts the navigations it starts, so a router transition commits as a same-document navigation instead of loading the document afresh. An application's extra work on those navigations — view transitions, analytics, progress UI — goes through the intercept option.

See ​

https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API

Extends ​

Constructors ​

Constructor ​

ts
new NavigationLocationService(router?, options?): NavigationLocationService;

Defined in: index.ts:160

Creates a new NavigationLocationService instance.

Parameters ​

ParameterTypeDescription
router?UIRouterThe UIRouter instance (required despite optional type signature)
options?NavigationLocationPluginOptionsHow the service intercepts its own navigations

Returns ​

NavigationLocationService

Throws ​

Error if router is not provided

Overrides ​

ts
BaseLocationServices.constructor

Methods ​

ts
protected _navigation(): Navigation;

Defined in: index.ts:290

The Navigation API object this service drives.

Single seam for every navigation touch point. Override in a subclass to substitute a stub — tests get to assert against the calls this service makes without booting a browser to spy on a global.

Returns ​

Navigation

Example ​

ts
class StubbedNavigationLocationService extends NavigationLocationService {
  protected override _navigation(): Navigation {
    return this.stub;
  }
}

dispose() ​

ts
dispose(router): void;

Defined in: index.ts:367

Cleans up the location service by removing its Navigation API listeners.

Parameters ​

ParameterTypeDescription
routerUIRouterThe UIRouter instance

Returns ​

void

Overrides ​

ts
BaseLocationServices.dispose