Adds an event handler that runs when the state of the toggle switch changes.
An element receives a change
event when a user changes the state of the toggle switch.
Because onChange()
is fired before validations are performed, don't check
any of the validation properties in the onChange()
event handler. For example,
don't code an if statement that checks the checked
property in the onChange()
because the property at this point contains values prior to the onChange()
.
handler(event: Event): void
The name of the function or
the function expression to run when the state of the toggle switch changes.