I have an Angular Formly form with a checkbox and I want to set a class on the wrapper based on if the field is checked or not.
So in the same way that I can do
expressionProperties: {
'templateOptions.label': '$viewValue'
}
is it possible to do something like
expressionProperties: {
'className': '$viewValue'
}
I don't seem to be able to get it to work.
Here's how you'd do it: https://jsbin.com/nerijo/edit?js,output
Basic idea: Your wrapper can reference the formControl
object to get the $viewValue
directly. You could also have it reference a data
property that you set with expressionProperties
. You could also use a templateManipulator
to add the template (instead of a wrapper). angular-formly is very flexible.