【发布时间】:2019-09-05 17:55:23
【问题描述】:
点击时需要检查一些条件,如果返回true,则切换点击的位置
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active" (click)='example()'>
<input type="radio" name="options" id="option1" autocomplete="off" checked> Active
</label>
<label class="btn btn-secondary" (click)='example()'>
<input type="radio" name="options" id="option2" autocomplete="off"> Radio
</label>
<label class="btn btn-secondary" (click)='example()'>
<input type="radio" name="options" id="option3" autocomplete="off"> Radio
</label>
</div>
【问题讨论】:
-
您可以将
$event传递给example(),这样您就可以访问事件属性,例如target和target.name/target.id。至少尝试以下方法。更改模板中的处理程序以传递$event(click)='example($event)'。然后更新处理程序以获取$event参数并根据需要使用它example($event) { console.log($event.target); }?
标签: html angular user-interface bootstrap-4