【发布时间】:2020-01-17 05:11:17
【问题描述】:
我正在使用 Angular 8 在模态中实现引导开关。
默认情况下,它处于off 状态,但是当我打开它on 并关闭模式时,它仍然处于on 状态。
HTML:
<div align="center" class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customSwitches">
<label class="custom-control-label" for="customSwitches">Try it</label>
</div>
TS 代码:
ngAfterViewInit(): void {
$('#modalDisplay').on('hidden.bs.modal', function () {
$('#customSwitches').attr(':checked', false);
}.bind(this));
}
【问题讨论】:
-
在 Angular 中使用 jQuery 是不好的做法...请从:stackoverflow.com/questions/42097796 寻求帮助
-
我通过使用“.prop”解决了这个问题,插入了实际的“.attr”
标签: jquery html angular bootstrap-4