changeEvents

Description

This value is used for do operations like disable field, enable field, set validator to the another field, remove validators of another field, set value to the another field on change of the field.

Hint

Type: Array<NgMatFormFields>

Example:

Fields: NgMatFormFields[] = [{
        type: 'input',
        label: 'User Name',
        placeholder: 'Enter a User Name',
        formControlName: 'name',
        directive: 'numericOnly',
        maxLength: '10',
        validators: [Validators.required, Validators.email]
    },{
    type: 'checkBox',
    label: 'Confirm Password',
    placeholder: 'Enter a Password',
    formControlName: 'checkbox',
    list: [
        {
            name: 'Infinity War',
            value: 'Avengers'
        }
    ],
    changeEvents: [{
        // If the value is true the following operations happen
        value: true, 
        // Array of formControl names which need to be disabled
        disable: ['name'], 
        // Array of formControl names which need to be enabled
        enable: ['name'], 
        //Array of FieldValueModel to set value for another controls of form group
        setValue: [{ formControlName: 'name', value: 'Satheesh' }], 
        // Array of formControl names which validators to removed
        removeValidators: ['name'], 
        //Array of FieldValueModel to set validators for another controls of form group
        setValidators: [{ formControlName: 'name', validators: [Validators.required] }]
    }]
}];

Last updated