I have two input fields with two slidetoggles. What I want to do is when I enable one slidetoggle, the respective field on that slidetoggle gets enabled and the 2nd slidetoggle and 2nd inputfield gets disabled.
Till now I have tried this:
When I click on slidetoggle it results in changing the state of 2nd slidetoggle which in turn gets the input field disabled but when I post its value its value still gets saved to database:
Here's the code I've tried:
HTML:
<div class="input-field">
<div>
<mat-label>Count(Number) </mat-label>
<mat-slide-toggle class="slide-right test" formControlName="count" [(ngModel)]="Count" (ngModelChange)="onCountOptionSelect($event);selectedSize=!selectedSize"
[checked]="isChecked"></mat-slide-toggle>
</div>
<div>
<mat-form-field class="csd-input-field" appearance="outline">
<input matInput type="number" class="input" placeholder="Enter Count" value="1" formControlName="count" [readonly]="countInputDisabled">
</mat-form-field>
<mat-label>Max: 100</mat-label>
</div>
</div>
<div class="input-field">
<div>
<mat-label>Size(KB) </mat-label>
<mat-slide-toggle class="slide-right" formControlName="size" [disabled]="test" [ngModel]="selectedSize" ></mat-slide-toggle >
</div>
<div>
<mat-form-field class="csd-input-field" appearance="outline">
<input matInput type="number" class="input" placeholder="Enter size" value="1" formControlName="size" [readonly]="sizeInputDisabled">
</mat-form-field>
<mat-label>Max: 1000KB</mat-label>
</div>
</div>
TS File
onCountOptionSelect(selectedCountVal) {
if (selectedCountVal == true) {
this.countInputDisabled = false;
this.sizeInputDisabled = true;
this.test=false;
} else {
}
this.countInputDisabled = true;
this.sizeInputDisabled = false;
this.test=true;
}
If anyone has any ideas how to get the text fields working in conjuncture to matslidetoggle, please help