title: Angular: Using $scope method in an object causes TypeError: undefined is not a function
body: <p>I'm getting the error: <code>TypeError: undefined is not a function</code> for this:</p>
  
  <p>controller:</p>
  
  <pre><code>$scope.dateRange = { before: $scope.oneMonthAgo(), after: new Date }; #&lt;------
  
  $scope.oneMonthAgo = function oneMonthAgo() {
    var date = new Date;
    date.setMonth(date.getMonth() - 1);
    return date;
  };
  </code></pre>
  
  <p>What's going on?? Is it because the object doesn't have access to the $scope method?</p>
  
  <p>When I change it to this, it prints out the correct value for <code>oneMonthAgo()</code>:</p>
  
  <pre><code>    $scope.dateRange            = { before: new Date, after: new Date };
  
  
      $scope.oneMonthAgo = function oneMonthAgo() {
        var date = new Date;
        date.setMonth(date.getMonth() - 1);
        return date;
      };
  
      console.log($scope.oneMonthAgo()); # prints Mon Nov 17 2014 11:56:15 GMT-0500 
  </code></pre>
  
  <p>What's the deal?</p>