# 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.
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 |
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 |
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 |
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 |
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.
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 |
void