1

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(){
            getAllCustomers();

        };

2 Answers 2

3

Remove new keyword while declaring function, It should be

$scope.getAllCustomers = function()
Sign up to request clarification or add additional context in comments.

Comments

1

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();

        };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.