From 71a42b19dbc9ab23bc3188492a5786104cdb7850 Mon Sep 17 00:00:00 2001 From: "Patrick Oswald (OSP)" Date: Tue, 16 Jan 2024 17:13:57 +0100 Subject: [PATCH] Fixed missing ngModuleRef --- .../src/components/placeholder.component.ts | 1 + .../sitecore-jss-angular/src/jss-component-factory.service.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sitecore-jss-angular/src/components/placeholder.component.ts b/packages/sitecore-jss-angular/src/components/placeholder.component.ts index 369b89e624..efebdb8e9c 100644 --- a/packages/sitecore-jss-angular/src/components/placeholder.component.ts +++ b/packages/sitecore-jss-angular/src/components/placeholder.component.ts @@ -296,6 +296,7 @@ export class PlaceholderComponent implements OnInit, OnChanges, DoCheck, OnDestr // work-around for https://github.com/angular/angular/issues/12215 const createdComponentRef = this.view.createComponent(rendering.componentImplementation, { index: index, + ngModuleRef: rendering.componentModuleRef, }); if (this.parentStyleAttribute) { this.renderer.setAttribute( diff --git a/packages/sitecore-jss-angular/src/jss-component-factory.service.ts b/packages/sitecore-jss-angular/src/jss-component-factory.service.ts index b07e2af55a..91250d81fe 100644 --- a/packages/sitecore-jss-angular/src/jss-component-factory.service.ts +++ b/packages/sitecore-jss-angular/src/jss-component-factory.service.ts @@ -1,4 +1,4 @@ -import { Inject, Injectable, Injector, Type, createNgModule } from '@angular/core'; +import { createNgModule, Inject, Injectable, Injector, NgModuleRef, Type } from '@angular/core'; import { ComponentRendering, HtmlElementRendering } from '@sitecore-jss/sitecore-jss/layout'; import { ComponentNameAndModule, @@ -17,6 +17,7 @@ export interface ComponentFactoryResult { // eslint-disable-next-line @typescript-eslint/no-explicit-any componentImplementation?: Type; componentDefinition: ComponentRendering | HtmlElementRendering; + componentModuleRef?: NgModuleRef; canActivate?: | JssCanActivate | Type @@ -86,6 +87,7 @@ export class JssComponentFactoryService { return { componentDefinition: component, componentImplementation: componentType, + componentModuleRef: moduleRef, canActivate: lazyComponent.canActivate, resolve: lazyComponent.resolve, };