I am working on angular app. I have some mat-toggle in my code. Code is as follows:
<form
class="example-form"
[formGroup]="formGroup"
(ngSubmit)="onFormSubmit(formGroup.value)"
ngNativeValidate
>
<mat-slide-toggle formControlName="enableWifi">Enable Wifi</mat-slide-toggle>
<mat-slide-toggle formControlName="acceptTerms"
>Accept Terms of Service</mat-slide-toggle
>
<p>Form Group Status: {{ formGroup.status}}</p>
<button mat-rasied-button type="submit">Save Settings</button>
<button mat-rasied-button type="submit">Activate All</button>
</form>
Stackblitz:
stackblitz.com/edit/mat-slide-toggle-example-guurez?file=app%2Fslide-toggle-overview-example.html
I have one button Activate All. If user clicks this button all the mat-toggle gets enabled and on and text of button is changed to Deactivate All and vice versa. In case if user goes and disable one toggle, again this button is changed to Activate ALL and on click of this button all toggle should be enabled and on and button should be set to Deactivate all and so on. How can I do that?