Clicking a checkbox with ng-click does not update the model

前端 未结 10 1664
太阳男子
太阳男子 2020-12-04 13:17

Clicking on a checkbox and calling ng-click: the model is not updated before ng-click kicks in so the checkbox value is wrongly presented in the UI:

This works in An

10条回答
  •  不思量自难忘°
    2020-12-04 13:37

    Why dont you use

    $watch('todo',function(.....
    

    Or another solution would be to set the todo.done inside the ng-click callback and only use ng-click

  • {{todo.text}} {{todo.done}}
  • and

    $scope.onCompleteTodo = function(todo) {
            todo.done = !todo.done; //toggle value
            console.log("onCompleteTodo -done: " + todo.done + " : " + todo.text);
            $scope.current = todo;
    }
    

提交回复
热议问题