0

这都是关于这个块的:

<div class="panel done-{{ todo.done }}" ng-repeat="todo in todos()" ng-click="changeStatus(todo)">
  <input type="checkbox" ng-model="todo.done"> {{ todo.title }}
</div>

删除外部 ng-click 复选框可以正常工作,不这样做只是 ng-click 将起作用。Ng-click 将更改复选框的值,但复选框不会更改状态。

$scope.changeStatus = function(todo) {
  todo.done = ! todo.done;
};
4

2 回答 2

0

现在可以工作了。这可能有点难看,但它有效:

<div class="panel done-{{ todo.done }}" ng-repeat="todo in todos()" ng-click="changeStatus(todo)">
  <input type="checkbox" ng-model="todo.done" ng-click="changeStatus(todo)"> {{ todo.title }}
</div>
于 2013-07-06T13:29:25.657 回答
0

ng-click 应该进入输入字段:

<div class="panel done-{{ todo.done }}" ng-repeat="todo in todos()" >
  <input type="checkbox" ng-model="todo.done" ng-click="changeStatus(todo)"/> {{ todo.title }}
</div>

你的功能应该有!附加到变量的运算符,否则它将失败:

$scope.changeStatus = function(todo) {
  todo.done = !todo.done;
};
于 2013-07-03T22:29:01.443 回答