我目前使用的是 angular 2.0。在HTML中,我有一个复选框,代码如下。
<div style="margin-left:15px;">
<label>Draw</label>
<input id="isCheckBox" type="checkbox" checked="checked">
</div>
如何仅在 typescript 文件中选中复选框时调用函数?
最佳答案
你可以这样做,
<input type="checkbox" id="isCheckBox" (change)="yourfunc($event)"/>
在 typescript 中,
yourfunc(e) {
if(e.target.checked){
}
}
关于angular - 如何调用一个函数来检查 Angular 2.0 中的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42678927/