title: how to define normal javascript function inside the controller in angularjs
body: <p>I have a code snippet below.</p>
  
  <p>sample.js</p>
  
  <pre><code>(function() {
      /*global angular */
      'use strict';
  
      angular.module('myapp', ['spinner'])
         .controller('myCtrl', ['$scope', '$window', function ($scope, $window ) {
  
      $scope.methodname = function() {
              if(something){
                  /* Doing some operations */
              }
      };
      /* Here I need to define the callme javascript function */
  
     function callme(response){
         /* If I call like this, I'm getting error in console. */
      }
  
      }]);  /* Controller ends here */
  
      /* Creating a new anonymous function to perform some operations */
      (function () {
      'use strict';
  
  
       /* Edited */
     code.util.myHTTP(url, function (response) {
  
               // Adding response to session storage
              callme(response);
  
               }, function () {
                 // Removing from session storage
          });
  
          })();
       }());
  </code></pre>
  
  <p>Here, I can't able to call callme javascript function inside angular controller . I'm getting error in console like</p>
  
  <pre><code>Uncaught ReferenceError: callme is not defined
  </code></pre>
  
  <p>Is there any way to achieve this?</p>
  
  <p>I need to use some controller parameters like $window inside callme function, that's why I'm defining callme function inside controller.</p>
  
  <p>I have run function in my js file already like below</p>
  
  <pre><code>.run(function($rootScope, $log, $window) {
  });
  </code></pre>
  
  <p>My requirement is like call anonymous function, on load there will be some api response, I need to call one method to process the response. because of these controller parameters, I wanted to define my method inside the controller. Is there any alternate way to achieve this?</p>