我需要在APP_INITIALIZER中解析网址。为了正确解析它,我需要访问其中的BASE_HREF。 有可能吗?
在当前方法'getImportantFromUrl'中,URL解析错误,导致现在不再需要base-href
// =====================
{
provide: APP_INITIALIZER,
useFactory: initializeApp,
deps: [...]
}
// =====================
export function initializeApp(...){
return () =>{
new Promise<any>((resolve: any) => {
const locationInitialized = injector.get(LOCATION_INITIALIZED,
Promise.resolve(null));
locationInitialized.then((x) => {
// todo: getImportantFromUrl should parse url taking in account base-href
var x = getImportantFromUrl(window.location.pathname);
}
};