diff --git a/libs/single-spa-angular/internals/src/dom.ts b/libs/single-spa-angular/internals/src/dom.ts index 2d7e220..67daeb5 100644 --- a/libs/single-spa-angular/internals/src/dom.ts +++ b/libs/single-spa-angular/internals/src/dom.ts @@ -19,7 +19,12 @@ export function getContainerElementAndSetTemplate string; + containerElement.innerHTML = template(props); + } else { + containerElement.innerHTML = options.template; + } return containerElement; } diff --git a/libs/single-spa-angular/internals/src/types.ts b/libs/single-spa-angular/internals/src/types.ts index 67eabe6..fb44d95 100644 --- a/libs/single-spa-angular/internals/src/types.ts +++ b/libs/single-spa-angular/internals/src/types.ts @@ -4,7 +4,7 @@ import { ApplicationRef, NgModuleRef } from '@angular/core'; export type DomElementGetter = (props: any) => HTMLElement; export interface BaseSingleSpaAngularOptions { - template: string; + template: string | Function; domElementGetter?: DomElementGetter; bootstrapFunction(props: AppProps): Promise | ApplicationRef>; } diff --git a/libs/single-spa-angular/src/single-spa-angular.ts b/libs/single-spa-angular/src/single-spa-angular.ts index 7949c1f..33d4102 100644 --- a/libs/single-spa-angular/src/single-spa-angular.ts +++ b/libs/single-spa-angular/src/single-spa-angular.ts @@ -38,8 +38,12 @@ export function singleSpaAngular(userOptions: SingleSpaAngularOptions): Li throw Error('single-spa-angular must be passed an options.bootstrapFunction'); } - if (NG_DEV_MODE && typeof options.template !== 'string') { - throw Error('single-spa-angular must be passed options.template string'); + if ( + NG_DEV_MODE && + typeof options.template !== 'string' && + typeof options.template !== 'function' + ) { + throw Error('single-spa-angular must be passed options.template string or function'); } if (NG_DEV_MODE && !options.NgZone) {