请你看一下这个片段,让我知道如何在Angularjs复选框中切换布尔值的状态,这里isChecked
通过控制器?
<body ng-app="app">
<div ng-controller="checkController">
<input type="checkbox" ng-model="choice" name="item" ng-change="changeSta(choice)" /> Add New Item
</div>
</body>
<script>
var app = angular.module('app', []);
app.controller('checkController', function($scope) {
var isChecked = false;
$scope.changeSta = function() {
//isChecked = true;
};
});
</script>
答案 0 :(得分:3)
您只需检查复选框模型中的更改:
var app = angular.module('app', []);
app.controller('checkController', function($scope) {
var isChecked = false;
$scope.changeSta = function() {
console.log($scope.choice);
};