On this page
LocationStrategy
class
LocationStrategy is responsible for representing and reading route state from the browser's URL. Angular provides two strategies: HashLocationStrategy and PathLocationStrategy.
abstract class LocationStrategy {
  abstract path(includeHash?: boolean): string
  abstract prepareExternalUrl(internal: string): string
  abstract pushState(state: any, title: string, url: string, queryParams: string): void
  abstract replaceState(state: any, title: string, url: string, queryParams: string): void
  abstract forward(): void
  abstract back(): void
  abstract onPopState(fn: LocationChangeListener): void
  abstract getBaseHref(): string
}
   
   Description
This is used under the hood of the Location service.
Applications should use the Router or Location services to interact with application route state.
For instance, HashLocationStrategy produces URLs like http://example.com#/foo, and PathLocationStrategy produces http://example.com/foo as an equivalent URL.
See these two classes for more.
Methods
| 
         
          path() 
          | 
      |||
|---|---|---|---|
        
          | 
      
includeHash | 
            boolean | 
            Optional. Default is   | 
           
Returns
string
| 
         
          prepareExternalUrl() 
          | 
      |||
|---|---|---|---|
        
          | 
      
internal | 
            string | 
            
Returns
string
| 
         
          pushState() 
          | 
      ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
        
          | 
      
state | 
            any | 
            |
title | 
            string | 
            |
url | 
            string | 
            |
queryParams | 
            string | 
            
Returns
void
| 
         
          replaceState() 
          | 
      ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
        
          | 
      
state | 
            any | 
            |
title | 
            string | 
            |
url | 
            string | 
            |
queryParams | 
            string | 
            
Returns
void
| 
         
          forward() 
          | 
      
|---|
        
          | 
      
| 
         
          back() 
          | 
      
|---|
        
          | 
      
| 
         
          onPopState() 
          | 
      |||
|---|---|---|---|
        
          | 
      
fn | 
            LocationChangeListener | 
            
Returns
void
| 
         
          getBaseHref() 
          | 
      
|---|
        
          | 
      
© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
 https://v7.angular.io/api/common/LocationStrategy