Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

BrowserPlatformLocation

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