结果始终为“ on”。我想使它在打开和关闭时都得到两个结果。
<label class="switch switch-3d switch-primary switch-success">
<input type="checkbox" (change)="isChangeLimitAccessToggle($event.target.value)" id="ifLimitAccess" class="switch-input">
<!-- [attr.disabled]="switchDisable?'':null" [checked]="switchEnable" -->
<span class="switch-label" data-on="Yes" data-off="No"></span>
<span class="switch-handle"></span>
</label>
答案 0 :(得分:2)
只需使用已选中属性:
<input type="checkbox" (change)="isChangeLimitAccessToggle($event.target.checked ? 'on' : 'off')" id="ifLimitAccess" class="switch-input">
答案 1 :(得分:1)
将[(ngModel)]指令添加到您的输入中:
<label class="switch switch-3d switch-primary switch-success">
<input type="checkbox" [(ngModel)]="checkboxValue"(change)="isChangeLimitAccessToggle(checkboxValue)" id="ifLimitAccess" class="switch-input">
<!-- [attr.disabled]="switchDisable?'':null" [checked]="switchEnable" -->
<span class="switch-label" data-on="Yes" data-off="No"></span>
<span class="switch-handle"></span>
答案 2 :(得分:0)
<input type="checkbox" value = "1"(change)="isChangeLimitAccessToggle($event.target.value)" class="switch-input">
您可以在输入标签中传递值,当您单击复选框时,您将获得1个值,因此它将为您工作。