角条件提供者功能

问题描述 投票:0回答:1

I有一个角(18.2) +电子(26)应用,该应用需要伸缩,而在网络上运行时不需要此。

在标准app.config.ts中,我只是将下面的extron

用于电子

provideRouter: (routes, withHashLocation())

如何使这种动态化,以便在不添加电子时不会添加删除?

检查角网站是否在电子下运行的唯一方法是以下语句,当加载app.config.ts时,它感觉不可能访问。

this.windowReference.api && this.windowReference.api.isElectron
    
angular electron
1个回答
0
投票
app.config.ts

)有条件地分配它:

const isElectron = this.windowReference?.api?.isElectron;
const routerProviders = isElectron ? provideRouter(routes, withHashLocation()) : provideRouter(routes);

export const appConfig: ApplicationConfig = {
  providers: [routerProviders]
};

	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.