我已检查问题How to bind to list of checkbox values with AngularJS 。但是这个问题解释了数组列表以及在 Angular Controller 中处理它的最佳方法。
<input type='checkbox' name="filter" checked>
如何将值绑定(bind)到复选框,以便在未选中时将值设置为模态 0,在选中时将值设置为 1? HTML 和 Controller 中应该包含什么?
$scope.filter = 0;
最佳答案
试试这个:
$scope.filter = 0;//or 1
HTML:
<input type="checkbox" ng-model="filter" ng-true-value="1" ng-false-value="0">
关于javascript - 如何使用 AngularJS Controller 绑定(bind)单个复选框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38843593/