2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2017-01-03 16:54:46 -08:00
|
|
|
import {InjectionToken} from '@angular/core';
|
2016-08-23 14:26:31 -07:00
|
|
|
import {LocationChangeListener} from './platform_location';
|
2015-11-17 10:47:59 -08:00
|
|
|
|
2015-09-21 17:31:31 -07:00
|
|
|
/**
|
|
|
|
|
* `LocationStrategy` is responsible for representing and reading route state
|
2015-11-25 23:06:06 +01:00
|
|
|
* from the browser's URL. Angular provides two strategies:
|
2016-09-09 16:54:26 -07:00
|
|
|
* {@link HashLocationStrategy} and {@link PathLocationStrategy}.
|
2015-09-21 17:31:31 -07:00
|
|
|
*
|
|
|
|
|
* This is used under the hood of the {@link Location} service.
|
|
|
|
|
*
|
|
|
|
|
* Applications should use the {@link Router} or {@link Location} services to
|
|
|
|
|
* interact with application route state.
|
|
|
|
|
*
|
|
|
|
|
* For instance, {@link HashLocationStrategy} produces URLs like
|
|
|
|
|
* `http://example.com#/foo`, and {@link PathLocationStrategy} produces
|
|
|
|
|
* `http://example.com/foo` as an equivalent URL.
|
|
|
|
|
*
|
|
|
|
|
* See these two classes for more.
|
2016-05-27 11:24:05 -07:00
|
|
|
*
|
|
|
|
|
* @stable
|
2015-09-21 17:31:31 -07:00
|
|
|
*/
|
2015-09-25 14:48:17 -07:00
|
|
|
export abstract class LocationStrategy {
|
2016-06-26 11:52:32 -07:00
|
|
|
abstract path(includeHash?: boolean): string;
|
2015-10-26 13:57:41 +00:00
|
|
|
abstract prepareExternalUrl(internal: string): string;
|
2015-09-23 00:10:26 -07:00
|
|
|
abstract pushState(state: any, title: string, url: string, queryParams: string): void;
|
2015-12-07 16:05:57 -08:00
|
|
|
abstract replaceState(state: any, title: string, url: string, queryParams: string): void;
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract forward(): void;
|
|
|
|
|
abstract back(): void;
|
2016-08-23 14:26:31 -07:00
|
|
|
abstract onPopState(fn: LocationChangeListener): void;
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract getBaseHref(): string;
|
2015-06-22 12:14:19 -07:00
|
|
|
}
|
2015-09-23 00:10:26 -07:00
|
|
|
|
2015-11-17 10:47:59 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The `APP_BASE_HREF` token represents the base href to be used with the
|
|
|
|
|
* {@link PathLocationStrategy}.
|
|
|
|
|
*
|
|
|
|
|
* If you're using {@link PathLocationStrategy}, you must provide a provider to a string
|
|
|
|
|
* representing the URL prefix that should be preserved when generating and recognizing
|
|
|
|
|
* URLs.
|
|
|
|
|
*
|
|
|
|
|
* ### Example
|
|
|
|
|
*
|
2016-09-05 21:37:21 +08:00
|
|
|
* ```typescript
|
2016-08-16 11:15:01 -07:00
|
|
|
* import {Component, NgModule} from '@angular/core';
|
2016-04-28 17:50:03 -07:00
|
|
|
* import {APP_BASE_HREF} from '@angular/common';
|
2015-11-17 10:47:59 -08:00
|
|
|
*
|
2016-08-16 11:15:01 -07:00
|
|
|
* @NgModule({
|
|
|
|
|
* providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
|
|
|
|
|
* })
|
|
|
|
|
* class AppModule {}
|
2015-11-17 10:47:59 -08:00
|
|
|
* ```
|
2016-08-16 11:15:01 -07:00
|
|
|
*
|
2016-05-27 11:24:05 -07:00
|
|
|
* @stable
|
2015-11-17 10:47:59 -08:00
|
|
|
*/
|
2017-01-03 16:54:46 -08:00
|
|
|
export const APP_BASE_HREF = new InjectionToken<string>('appBaseHref');
|