libs/core-forms/src/lib/backend-integration-plugin/backend-integration-plugin.module.ts
No results matching.
| Static forRoot | ||||||
forRoot(optionsFactory?: (injector?: Injector) => void)
|
||||||
|
Parameters :
|
import {
inject,
InjectionToken,
Injector,
ModuleWithProviders,
NgModule,
signal,
Signal
} from '@angular/core';
import { BackendIntegrationPlugin } from './backend-integration-plugin';
export const CORE_FORMS_BACKEND_INTEGRATION_ACTION_TYPE = 'CORE_FORMS_BACKEND_INTEGRATION';
export interface CoreFormsBackendIntegrationPluginOptions {
formId: string;
tenant: string;
site: string;
instance: string;
talyTurnstileFormfieldId: string;
talyPrefix: string;
/**
* When true, generates a hash of visible form field IDs.
* @default false
*/
generateVisibilityHash?: boolean;
/**
* If true, appends form data to the external next page URL after submission.
* @default false
*/
appendFormDataToNextPageUrl?: boolean;
}
export const CORE_FORMS_BACKEND_INTEGRATION_PLUGIN_OPTIONS = new InjectionToken<
Signal<CoreFormsBackendIntegrationPluginOptions>
>('CORE_FORMS_BACKEND_INTEGRATION_PLUGIN_OPTIONS');
@NgModule({
providers: [BackendIntegrationPlugin]
})
export class BackendIntegrationPluginModule {
constructor() {
const backendIntegrationPlugin = inject(BackendIntegrationPlugin);
backendIntegrationPlugin.registerActions();
}
static forRoot(
optionsFactory?: (
injector: Injector
) => Signal<CoreFormsBackendIntegrationPluginOptions | undefined>
): ModuleWithProviders<BackendIntegrationPluginModule> {
const defaultFactory = () =>
signal<CoreFormsBackendIntegrationPluginOptions | undefined>(undefined);
return {
ngModule: BackendIntegrationPluginModule,
providers: [
{
provide: CORE_FORMS_BACKEND_INTEGRATION_PLUGIN_OPTIONS,
useFactory: optionsFactory || defaultFactory,
deps: [Injector]
}
]
};
}
}