Create a component and extends/implements it with the abstract class CustomFormLabel
.
import { Component } from '@angular/core';
import { CustomFormLabel } from 'ng-dynamic-json-form';
@Component({
...
})
export class CustomFormLabelComponent extends CustomFormLabel {}
Create a ng-template, and add the properties needed.
<ng-template #customLabelTemplate let-label="label" let-layout="layout" ...> ... </ng-template>
Name | Type | Description |
---|---|---|
collapsible | boolean | Whether the content of this input is collapsible. |
expand | boolean | The expand state of the content of this input. |
label | string | The text for this label. |
layout | FormLayout | The layout from the FormControlConfig of this input. |
props | any | The props from the FormControlConfig of this input. |
import { Component } from '@angular/core';
import { provideNgDynamicJsonForm } from 'ng-dynamic-json-form';
import { CustomFormLabelComponent } from '...';
@Component({
...
providers: [
provideNgDynamicJsonForm({
...
labelComponent: CustomFormLabelComponent
}),
]
})
<ng-dynamic-json-form
...
[labelComponentDefault]="labelComponent"
></ng-dynamic-json-form>
import { CustomLabelComponent } from "...";
labelComponent = CustomLabelComponent;
<ng-dynamic-json-form
...
[labelTemplateDefault]="defaultLabelTemplate"
></ng-dynamic-json-form>
<ng-template #defaultLabelTemplate let-label="label">...</ng-template>
Provide either labelComponents
or labelTemplates
using property binding. The formControlName
is use as the key to specify which label needs to be replaced.
<ng-dynamic-json-form
...
[labelComponents]="labelComponents"
></ng-dynamic-json-form>
labelComponents = {
name: ...,
age: ...
}
<ng-dynamic-json-form
...
[labelTemplates]="{
name: nameLabelTemplate,
age: ageLabelTemplate
}"
></ng-dynamic-json-form>
<ng-template #nameLabelTemplate let-label="label">...</ng-template>
<ng-template #ageLabelTemplate let-label="label">...</ng-template>