title: Why does ng-click on checkbox update the value of array after function is called?
body: <p>I have an array with persons who have scores. I display with the list of persons with their scores and a checkbox. When the user checks the checkbox, I total all scores that are checked.:
  <a href="http://jsfiddle.net/edwardtanguay/hwutbgv3/16" rel="nofollow">http://jsfiddle.net/edwardtanguay/hwutbgv3/16</a></p>
  
  <p>However, the totals are one check behind since it seems that when Angular executes the function contained in <code>ng-click</code>, it has not updated the value of <code>ng-model</code>.</p>
  
  <p><strong>How can I get Angular to update the value FIRST, and then execute the function?</strong></p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
      &lt;ul&gt;
          &lt;li ng-repeat="person in persons | orderBy:'score'"&gt;&lt;input type="checkbox" ng-model="person.isChecked" ng-click="updateTotals()"/&gt; {{person.name}} = {{person.score}} ({{person.isChecked}}) 
  
          &lt;/li&gt;
      &lt;/ul&gt;
      &lt;div&gt;{{message}}&lt;/div&gt;
      &lt;div&gt;total score of checked persons: {{total}}&lt;/div&gt;
  &lt;/div&gt; 
  </code></pre>
  
  <hr>
  
  <pre><code>var myApp = angular.module('myApp',[]);
  
  function MyCtrl($scope, $window) {
  
      $scope.debug = '';
      $scope.total = 0;
  
      $scope.persons = [
          {score: 1, name: 'Jim', isChecked: true},
          {score: 2, name: 'Joe', isChecked: false},
          {score: 3, name: 'Angie', isChecked: true}
      ];
  
      $scope.updateTotals = function() {
          $scope.total = 0;
          for(var x=0; x &lt; $scope.persons.length; x++) {
              var person = $scope.persons[x];
              if(person['isChecked']) {
                  $scope.total += person['score'];   
              }
          }
      }
  
      $scope.updateTotals()
  }
  </code></pre>