How to change **glyphicon" (right side of input field (see below)) on validation of input type ?
eg. When input is valid, change it to glyphicon-ok (tick mark ) or when it is invalid change it to glyphicon-remove ( cross sign )

vm.rentalFields = [
{
key: 'first_name',
type: 'input',
// class:glyphicon-ok,
templateOptions: {
type: 'text',
label: 'First Name',
placeholder: 'Enter your first name',
required: true,
"addonRight": {
"class": "glyphicon glyphicon-ok form-control-feedback"
}
}
}];
With angular-formly, if you want anything to be dynamic, you use
expressionProperties. Because you want theclassproperty ofaddonRightto be dynamic, yourexpressionPropertiesproperty for that will be:The values of
expressionPropertiesare called formly expressions which basically means they can be strings which are evaluated on theformly-field's$scopeor a function that is passed($viewValue, $modelValue, scope)and can return the value or a promise that resolves to the value.The
fcyou see in that expression is a shortcut foroptions.formControlwhich is assigned to your field'sNgModelController(which is why you have access to$valid.At the end of the day, your field config will look something like this: