在APP_INITIALIZER

时间:2019-09-04 15:23:43

标签: angular

我需要在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);
}
};

0 个答案:

没有答案