W3cubDocs

/Angular 12

MockPlatformLocation

class final

Mock implementation of URL state.

class MockPlatformLocation implements PlatformLocation {
  hostname
  protocol
  port
  pathname
  search
  hash
  state
  href: string
  url: string
  getBaseHrefFromDOM(): string
  onPopState(fn: LocationChangeListener): VoidFunction
  onHashChange(fn: LocationChangeListener): VoidFunction
  replaceState(state: any, title: string, newUrl: string): void
  pushState(state: any, title: string, newUrl: string): void
  forward(): void
  back(): void
  historyGo(relativePosition: number = 0): void
  getState(): unknown
}

Properties

Property Description
hostname Read-Only
protocol Read-Only
port Read-Only
pathname Read-Only
search Read-Only
hash Read-Only
state Read-Only
href: string Read-Only
url: string Read-Only

Methods

getBaseHrefFromDOM(): string

Parameters

There are no parameters.

Returns

string

onPopState(fn: LocationChangeListener): VoidFunction

Parameters
fn LocationChangeListener
Returns

VoidFunction

onHashChange(fn: LocationChangeListener): VoidFunction

Parameters
fn LocationChangeListener
Returns

VoidFunction

replaceState(state: any, title: string, newUrl: string): void

Parameters
state any
title string
newUrl string
Returns

void

pushState(state: any, title: string, newUrl: string): void

Parameters
state any
title string
newUrl string
Returns

void

forward(): void

Parameters

There are no parameters.

Returns

void

back(): void

Parameters

There are no parameters.

Returns

void

historyGo(relativePosition: number = 0): void

Parameters
relativePosition number

Optional. Default is 0.

Returns

void

getState(): unknown

Parameters

There are no parameters.

Returns

unknown

© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v12.angular.io/api/common/testing/MockPlatformLocation