Can anyone provide guidance on how to programmatically toggle
the toggle()
function in the code below?
template
<mat-slide-toggle color="primary" (change)="updateFunc($event)"></mat-slide-toggle>
ts
updateFunc(e) {
// perform checks for activation
// if cannot be activated, revert back to off position
e.checked = false;
e.toggle();
}
Any suggestions or solutions?
--UPDATE--
Just to clarify, after triggering the change event, the slider is toggled to the on position. My goal is to run tests and then toggle the slider back to the off position if certain conditions are not met. How can I achieve this using the toggle() method or by unchecking the switch in my code?