Я получаю сообщение об ошибке всякий раз, когда запускаю ng build Angular 8:
ERROR in Error during template compile of 'HomeModule'
Function calls are not supported in decorators but 'checkIfIsOnDomain' was called.
Как я могу это исправить? Мне нужно загрузить другой набор маршрутов в зависимости от того, находится ли пользователь на поддомене или нет. Код отлично работает на ng serve.
const routes: Routes = [
{path: '', component: HomeComponent}
];
@NgModule({
declarations: [
HomeComponent,
],
imports: [
RouterModule.forChild(RouterService.checkIfIsOnDomain() ? routes : RouterService.getSubdomainRoutes('../..')),
],
exports: [
],
})
Код в RouterService:
static checkIfIsOnDomain() {
const full = window.location.host;
const parts = full.split('.');
let result = true;
if (parts[0] && parts[1] && parts[2]) {
result = false;
(window as any).Intercom('update', {
'hide_default_launcher': true
});
}
return result;
}
static getSubdomainRoutes(path) {
return [
{ path: '', loadChildren: `${path}/website/website.module#WebsiteModule` }
];
}