单击时需要检查某些条件,如果返回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>
答案 0 :(得分:1)
您可以使用如下方法:
status:boolean;
someMethod(value: string): void {
this.status = value;
if (your condition) {
//Your operation here
} else {
//your other work.
}
}
此处的状态将帮助您存储值并应用条件。