title: Cannot get model value in Controller method in Angular js
body: <p>I am developing an app in Angular js </p>
  
  <p>javascript:</p>
  
  <pre><code>  $scope.spentAmount = function() {   
      angular.forEach($scope.expenses, function(expense) {
      if(expense.done){
      console.log($scope.spentamount);
      }     
      }); 
      //return amount;    
    };
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;label for="spentby"&gt;Spent by&lt;/label&gt;
           &lt;ul class="unstyled"&gt;
        &lt;li ng-repeat="expense in expenses"&gt;
          &lt;input type="checkbox" ng-model="expense.done"&gt;
          &lt;span&gt;{{expense.text}}&lt;/span&gt;
  
          &lt;input type="text"  ng-show="expense.done" ng-model="spentamount"  size="30"
               placeholder="Enter the amount"&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
      &lt;form ng-submit="addExpense()"&gt;
        &lt;input type="text" ng-model="expenseText"  size="30"
               placeholder="Enter the names"&gt;
        &lt;input class="btn-primary" type="submit" value="Add"&gt;
      &lt;/form&gt;
  &lt;label for="amountspent"&gt;Amount spent(Rs)&lt;/label&gt;
   &lt;span&gt;{{spentAmount()}}&lt;/span&gt;&lt;br&gt;
  </code></pre>
  
  <p>but <code>console.log($scope.spentamount)</code> returns undefined.</p>
  
  <p>But the method gets called
  Please Advice</p>