title: Declaring functions and properties in the scope of angularjs controller but not attached to $scope
body: <p>As of recently I have been declaring functions and properties for my angularJS controllers in the following way (app is set to the main apps angular module):</p>
  
  <pre><code>app.controller('myController', ['$scope', function($scope) {
      $scope.myProperty = "hello world";
      $scope.myFunc = function() {
          // do stuff
      };
  }]);
  </code></pre>
  
  <p>After a while the controllers' $scope grew to contain many utility functions and properties that are not being used directly in my views and would not be applicable to other controllers, so I changed it to this:</p>
  
  <pre><code>app.controller('myController', ['$scope', function($scope) {
      var myProperty = 0, addOne;
  
      addOne = function(i) {
          return i++;
      };
  
      $scope.myFunc = function() {
          myProperty = addOne(myProperty);
          // do other stuff
      };
  }]);
  </code></pre>
  
  <p>This is working fine but is it okay to declare functions and properties the way shown above or should I extract them out into a service? Can I unit test var declared functions in my controller from jasmine/karma(tried but did not succeed)? What is the best pattern to follow?</p>
  
  <p>I have looked into using the 'this' keyword to accomplish the same thing shown above but I don't think the added value would outweigh the amount of time it would take to convert everything to this pattern. If this is totally wrong please advise a better strategy.</p>
  
  <p><strong>--- Update ---</strong></p>
  
  <p>To answer my own question about testing var declared functions in the controller: <a href="https://stackoverflow.com/questions/22921484/how-can-we-test-non-scope-angular-controller-methods">How can we test non-scope angular controller methods?</a></p>