Function
resolveTokens
@ng-forge/dynamic-forms
Resolves special tokens in event arguments to their actual values
Supported tokens: - $key: The current field key - $index: The array index (if inside an array field) - $arrayKey: The parent array field key (if inside an array field) - $template: The template for array item creation - formValue: Reference to the current form value for indexing
Signature
function resolveTokens(
args: readonly (string | number | boolean)[],
context: TokenContext
): unknown[]Parameters
| Name | Type | Description |
|---|---|---|
args | readonly (string | number | boolean)[] | - Array of arguments that may contain tokens |
context | TokenContext | - Context object containing token values |
Returns
unknown[]
Examples
resolveTokens(['$arrayKey', '$index'], { arrayKey: 'contacts', index: 2 })
// Returns: ['contacts', 2]resolveTokens(['$key', 'static'], { key: 'myField' })
// Returns: ['myField', 'static']resolveTokens(['$arrayKey', '$template'], { arrayKey: 'contacts', template: [{ key: 'name', type: 'input' }] })
// Returns: ['contacts', [{ key: 'name', type: 'input' }]]packages/dynamic-forms/src/lib/events/utils/token-resolver.ts:43