libs/common/web-components/src/noop-location-strategy/noop-location-strategy.ts
Methods |
constructor(_platformLocation: PlatformLocation, href: string)
|
|||||||||
Parameters :
|
back |
back()
|
Returns :
void
|
forward |
forward()
|
Returns :
void
|
getBaseHref |
getBaseHref()
|
Returns :
string
|
getState |
getState()
|
Returns :
void
|
onPopState |
onPopState()
|
Returns :
void
|
path |
path()
|
Returns :
string
|
prepareExternalUrl |
prepareExternalUrl()
|
Returns :
string
|
pushState |
pushState()
|
Returns :
void
|
replaceState |
replaceState()
|
Returns :
void
|
import { APP_BASE_HREF, LocationStrategy, PlatformLocation } from '@angular/common';
import { Inject, Injectable, Optional } from '@angular/core';
@Injectable()
export class NoopLocationStrategy extends LocationStrategy {
private _baseHref: string;
constructor(
private _platformLocation: PlatformLocation,
@Optional() @Inject(APP_BASE_HREF) href: string
) {
super();
if (!href) {
href = this._platformLocation.getBaseHrefFromDOM();
}
if (!href) {
// No APP_BASE_HREF given and no <base> element present in
// this document. As this will be part of a web component we don't
// really care since we only rely on the DEPLOY_URL.
// Using empty string as a fallback.
href = '';
}
this._baseHref = href;
}
override getBaseHref(): string {
return this._baseHref;
}
override path(): string {
return '';
}
override prepareExternalUrl(): string {
return this._platformLocation.href;
}
override pushState(): void {}
override replaceState(): void {}
override onPopState(): void {}
override forward(): void {}
override back(): void {}
override getState(): void {}
}