Class

NgxRenderingEngine

lib/engine/NgxRenderingEngine.NgxRenderingEngine()

Constructor

# new NgxRenderingEngine()

This class extends the base RenderingEngine to provide Angular-specific rendering capabilities. It handles the conversion of field definitions to Angular components, manages component registration, and provides utilities for component creation and input handling. The engine converts model decorator metadata into dynamically created Angular components with proper input binding and lifecycle management.

Angular implementation of the RenderingEngine for Decaf components.

sequenceDiagram participant Client participant Engine as NgxRenderingEngine participant Components as RegisteredComponents Client->>Engine: get() Client->>Engine: initialize() Client->>Engine: render(model, props, vcr, injector, tpl) Engine->>Engine: toFieldDefinition(model, props) Engine->>Engine: fromFieldDefinition(fieldDef, vcr, injector, tpl) Engine->>Components: components(fieldDef.tag) Components-->>Engine: component constructor Engine->>Engine: createComponent(component, inputs, metadata, vcr, injector, template) Engine-->>Client: return AngularDynamicOutput

View Source lib/engine/NgxRenderingEngine.ts, line 18

Example
```typescript
const engine = NgxRenderingEngine.get();
engine.initialize();
const output = engine.render(myModel, {}, viewContainerRef, injector, templateRef);
```

Extends

  • RenderingEngine

Methods

# static components(selectoropt) → {Object|Array}

This static method retrieves either all registered components or a specific component by its selector. When called without a selector, it returns an array of all registered components. When called with a selector, it returns the specific component if found, or throws an error if the component is not registered.

Retrieves registered components from the rendering engine.

Parameters:
Name Type Attributes Description
selector string <optional>

Optional selector to retrieve a specific component

View Source lib/engine/NgxRenderingEngine.ts, line 758

Either a specific component or an array of all components

Object | Array

# static createComponent(component, inputsopt, metadata, vcr, injector, templateopt) → {ComponentRef.<unknown>}

This static utility method creates an Angular component instance with the specified inputs and template. It uses Angular's component creation API to instantiate the component and then sets the input properties using the provided metadata.

Creates an Angular component instance with inputs and template projection.

Parameters:
Name Type Attributes Default Description
component Type.<unknown>

The component type to create

inputs KeyValue <optional>
{}

The input properties to set on the component

metadata ComponentMirror.<unknown>

The component metadata for input validation

vcr ViewContainerRef

The view container reference for component creation

injector Injector

The Angular injector for dependency injection

template Array.<Node> <optional>
[]

The template nodes to project into the component

View Source lib/engine/NgxRenderingEngine.ts, line 660

The created component reference

ComponentRef.<unknown>

# async static destroy(formIdopt) → {Promise.<void>}

This static method clears the current instance reference and parent props, effectively destroying the singleton instance of the rendering engine. Optionally removes the form registry for the specified form ID. This can be used to reset the engine state or to prepare for a new instance creation.

Destroys the current engine instance and cleans up resources.

Parameters:
Name Type Attributes Description
formId string <optional>

Optional form ID to remove from registry

View Source lib/engine/NgxRenderingEngine.ts, line 687

A promise that resolves when the instance is destroyed

Promise.<void>

# static registerComponent(name, constructor) → {void}

This static method registers a component constructor with the rendering engine under a specific name. It initializes the components registry if needed and throws an error if a component is already registered under the same name to prevent accidental overrides.

Registers a component with the rendering engine.

Parameters:
Name Type Description
name string

The name to register the component under

constructor Constructor.<unknown>

The component constructor

View Source lib/engine/NgxRenderingEngine.ts, line 745

void

# static setInputs(component, inputs, metadata) → {void}

This static utility method sets input properties on a component instance based on the provided inputs object and component metadata. It handles both simple values and nested objects, recursively processing object properties. The method validates each input against the component's metadata to ensure only valid inputs are set.

Sets input properties on a component instance.

sequenceDiagram participant Caller participant SetInputs as setInputs participant Parse as parseInputValue participant Component as ComponentRef Caller->>SetInputs: setInputs(component, inputs, metadata) SetInputs->>SetInputs: Iterate through inputs loop For each input SetInputs->>SetInputs: Check if input exists in metadata alt Input is 'props' SetInputs->>Parse: parseInputValue(component, value) Parse->>Parse: Recursively process nested objects Parse->>Component: setInput(key, value) else Input is valid SetInputs->>Component: setInput(key, value) end end
Parameters:
Name Type Description
component ComponentRef.<unknown>

The component reference to set inputs on

inputs KeyValue

The input properties to set

metadata ComponentMirror.<unknown>

The component metadata for input validation

View Source lib/engine/NgxRenderingEngine.ts, line 793

void