W3cubDocs

/Angular

BrowserPlatformLocation

class final

PlatformLocation encapsulates all of the direct calls to platform APIs. This class should not be used directly by an application developer. Instead, use Location.

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

  // inherited from common/PlatformLocation
  abstract href: string
  abstract protocol: string
  abstract hostname: string
  abstract port: string
  abstract pathname: string
  abstract search: string
  abstract hash: string
  abstract getBaseHrefFromDOM(): string
  abstract getState(): unknown
  abstract onPopState(fn: LocationChangeListener): VoidFunction
  abstract onHashChange(fn: LocationChangeListener): VoidFunction
  abstract replaceState(state: any, title: string, url: string): void
  abstract pushState(state: any, title: string, url: string): void
  abstract forward(): void
  abstract back(): void
  historyGo(relativePosition: number)?: void
}

Provided in

  • 'platform'

Properties

Property Description
href: string Read-Only
protocol: string Read-Only
hostname: string Read-Only
port: string Read-Only
pathname: string
search: string Read-Only
hash: 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

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

Parameters
state any
title string
url string
Returns

void

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

Parameters
state any
title string
url 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–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/common/BrowserPlatformLocation