NG Dynamic Forms Material UI
Installation
npm i @ng-dynamic-forms/ui-material -S
Import
@NgModule({
imports: [DynamicFormsMaterialUIModule]
})
export class AppModule {}
Usage
with DynamicMaterialFormComponent
:
<form [formGroup]="myFormGroup">
<dynamic-material-form [group]="myFormGroup"
[model]="myFormModel"></dynamic-material-form>
</form>
with DynamicMaterialFormControlComponent
:
<form [formGroup]="myFormGroup">
<dynamic-material-form-control *ngFor="let controlModel of myFormModel"
[group]="myFormGroup"
[model]="controlModel"></dynamic-material-form-control>
</form>
Form Controls
Custom UI Events
<form [formGroup]="myFormGroup">
<dynamic-material-form [group]="myFormGroup"
[model]="myFormModel"
(matEvent)="onMatEvent($event)"></dynamic-material-form>
</form>
Resources
10.1.0
Features
Customizing the condition for displaying validation error messages can now be achieved by providing a
DynamicErrorMessagesMatcher
via newly introduced injection token DYNAMIC_ERROR_MESSAGES_MATCHER
:
function myCustomErrorMessagesMatcher (control: AbstractControl, model: DynamicFormControlModel, hasFocus: boolean) {
return //...
};
providers: [
{
provide: DYNAMIC_ERROR_MESSAGES_MATCHER,
useValue: myCustomErrorMessagesMatcher
},
By default the DEFAULT_ERROR_STATE_MATCHER
is active:
export const DEFAULT_ERROR_STATE_MATCHER: DynamicErrorMessagesMatcher =
(control: AbstractControl, model: DynamicFormControlModel, hasFocus: boolean) => {
return control.touched && !hasFocus;
};
Please read the updated chapter on validation messaging