title: AngularJS: When to pass $scope variable to function
body: <p>I am using the <a href="http://todomvc.com/architecture-examples/angularjs/#/">TodoMVC</a> app to get better with the AngularJS framework. In the <a href="https://github.com/tastejs/todomvc/blob/gh-pages/architecture-examples/angularjs/index.html">index.html</a> on lines 14-16 you see this:</p>
  
  <pre><code>&lt;form id="todo-form" ng-submit="addTodo()"&gt;
      &lt;input id="new-todo" placeholder="What needs to be done?" ng-model="newTodo" autofocus&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Notice how the <em>ng-submit</em> directive calls the <em>addTodo()</em> function without the <em>newTodo</em> model being passed as an argument.</p>
  
  <p>A short time later I came across the following code in the very same file on line 19:</p>
  
  <pre><code>&lt;input id="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll(allChecked)"&gt;
  </code></pre>
  
  <p>You can see the author decided to pass the <em>allChecked</em> model to the <em>markAll()</em> function this time. If I understand correctly, they could have referenced <em>$scope.allChecked</em> inside the controller instead of passing it in.</p>
  
  <p>Why use two different approaches in the same file? Is one approach better in some circumstances? Is this a case of inconsistency or is there a deeper logic being used?</p>