PathLocationStrategy

export class PathLocationStrategy

exported from angular2/router defined in angular2/src/router/path_location_strategy.ts (line 11)

PathLocationStrategy is a LocationStrategy used to configure the Location service to represent its state in the path of the browser's URL.

PathLocationStrategy is the default binding for LocationStrategy provided in ROUTER_PROVIDERS.

If you're using PathLocationStrategy, you must provide a provider for APP_BASE_HREF to a string representing the URL prefix that should be preserved when generating and recognizing URLs.

For instance, if you provide an APP_BASE_HREF of '/my/app' and call location.go('/foo'), the browser's URL will become example.com/my/app/foo.

Example

import {Component, provide} from 'angular2/core'; import { APP_BASE_HREF ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig, Location } from 'angular2/router'; @Component({directives: [ROUTER_DIRECTIVES]}) @RouteConfig([ {...}, ]) class AppCmp { constructor(location: Location) { location.go('/foo'); } } bootstrap(AppCmp, [ ROUTER_PROVIDERS, // includes binding to PathLocationStrategy provide(APP_BASE_HREF, {useValue: '/my/app'}) ]);

Annotations

@Injectable()

Constructor

constructor(_platformLocation: PlatformLocation, href?: string)

Not Yet Documented

Members

onPopState(fn: EventListener) : void

Not Yet Documented

getBaseHref() : string

Not Yet Documented

prepareExternalUrl(internal: string) : string

Not Yet Documented

path() : string

Not Yet Documented

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

Not Yet Documented

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

Not Yet Documented

forward() : void

Not Yet Documented

back() : void

Not Yet Documented