diff --git a/src/app/login-page/autoregistration/autoregistration-loader.component.ts b/src/app/login-page/autoregistration/autoregistration-loader.component.ts new file mode 100644 index 00000000000..87d7e86a8be --- /dev/null +++ b/src/app/login-page/autoregistration/autoregistration-loader.component.ts @@ -0,0 +1,34 @@ +import { Component, Inject, OnInit, PLATFORM_ID, ViewChild, ViewContainerRef, ComponentFactoryResolver } from '@angular/core'; +import { isPlatformBrowser } from '@angular/common'; + +/** + * Component that dynamically loads the AutoregistrationComponent only in the browser + */ +@Component({ + selector: 'ds-autoregistration-loader', + template: '', +}) +export class AutoregistrationLoaderComponent implements OnInit { + @ViewChild('dynamicComponent', { read: ViewContainerRef }) dynamicComponent: ViewContainerRef; + + isBrowser: boolean; + + constructor( + @Inject(PLATFORM_ID) private platformId: object, + private componentFactoryResolver: ComponentFactoryResolver + ) { + this.isBrowser = isPlatformBrowser(this.platformId); // Check if running in the browser + } + + ngOnInit(): void { + if (this.isBrowser) { + // Dynamically load the AutoregistrationComponent only in the browser + import('./autoregistration.component').then(({ AutoregistrationComponent }) => { + const componentFactory = + this.componentFactoryResolver.resolveComponentFactory(AutoregistrationComponent); + const componentRef = this.dynamicComponent.createComponent(componentFactory); + componentRef.changeDetectorRef.detectChanges(); + }); + } + } +} diff --git a/src/app/login-page/autoregistration/autoregistration.component.html b/src/app/login-page/autoregistration/autoregistration.component.html index 8b100217b57..8c2343ab387 100644 --- a/src/app/login-page/autoregistration/autoregistration.component.html +++ b/src/app/login-page/autoregistration/autoregistration.component.html @@ -1,4 +1,4 @@ -
+
{{'clarin.autoregistration.welcome.message' | translate}} {{dspaceName$ | async}}