如何解决将false设置为[checkbox] DOM属性,不要取消选中Angular中的复选框
当用户单击停止单选按钮时,我试图取消选中循环时间复选框,但未取消选中循环时间复选框。
Stackblitz网址-https://stackblitz.com/edit/angular-ivy-s3ryzm?file=src/app/app.component.html
复制步骤:
- 点击 GotoStream 单选按钮。
- 选中循环时间复选框
- 点击停止单选按钮,必须取消选中循环时间复选框,但不要取消选中该复选框。
下面是模板视图。
<div class="form-group ml-3">
<div class="radio">
<label>
<input type="radio" name="optradio" checked [disabled]="Stop" (change)="dropDownStream=true; timeInLoopChecked=false; timeInLoop=true; timeInLoopInput=true" > Stop
</label>
</div>
<div class="radio" >
<label class="float-left w-25 mt-2 mr-2">
<input type="radio" name="optradio" [disabled]="goToStream" (change)="dropDownStream = false; timeInLoopChecked=false; timeInLoop=false; timeInLoopInput=true" > GotoStream
</label>
<select class="custom-select float-left" style="width: 70%;" [disabled] = "dropDownStream">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
</div>
</div>
<div class="form-group vertical-group ml-3" style="clear: both;">
<div class="checkbox">
<label class="float-left w-25 mt-2 mr-2">
<input type="checkbox" value="" [checked]="timeInLoopChecked" [disabled]="timeInLoop" (change)="timeInLoopInput=!timeInLoopInput" > Time in Loop
</label>
<input class="float-left" style="width: 70%;" placeholder="0" type="text" class="form-control" id="streamName" autocomplete="off" [disabled]="timeInLoopInput"/>
</div>
</div>
下面是组件文件:
export class AppComponent {
dropDownStream: boolean = true;
timeInLoop: boolean = true;
Stop: boolean=false;
goToStream: boolean = false;
timeInLoopInput: boolean = true;
timeInLoopChecked: boolean = false;
}
当用户点击停止单选按钮时,如何取消循环时间复选框的选择?
谢谢, 莫汉
解决方法
只需更改此行:
<input type="radio" name="optradio" [disabled]="goToStream" (change)="dropDownStream = false; timeInLoopChecked=true; timeInLoop=false; timeInLoopInput=true" > GotoStream
https://stackblitz.com/edit/angular-ivy-mbwfy2?file=src/app/app.component.html
您没有在单选按钮上切换timeInLoopChecked
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。