Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

I have this code and I have made a refresh function which states the purpose obviously. I have to refresh other stats as well but I can't call it inside the "refresh" function below even they are in same scope. I am sure that I am calling it right but console keeps giving the following error:

ReferenceError: getAllCustomers is not defined

  $scope.getAllCustomers = new function(){
        $http.post('
          <?php echo site_url('angularjs/get_users_by_type/'); ?>',
                          {userType:'C'}).then(function(response) {

         $scope.totalCustomer = response.data.count;

      }, function(response) {
          console.log(response);
        // called asynchronously if an error occurs
        // or server returns response with an error status.
      });
    };

   // getAllCustomer etc all defined before this function but the following errors keeps coming on the console that getAllCustomers is not a function. 
        $scope.refresh = new function(){
            $scope.getAllCustomers();

        };
share|improve this question

2 Answers 2

up vote 3 down vote accepted

Remove new keyword while declaring function, It should be

$scope.getAllCustomers = function()
share|improve this answer

check your code like this:

   $scope.getAllCustomers = function(){
        $http.post('
          <?php echo site_url('angularjs/get_users_by_type/'); ?>',
                          {userType:'C'}).then(function(response) {

         $scope.totalCustomer = response.data.count;

      }, function(response) {
          console.log(response);

      });
    };


        $scope.refresh = function(){
            $scope.getAllCustomers();

        };
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.