0

I have a function that makes a request to a WS and send a response in JSON format like this.

$scope.goRequest = function ($scope) {

        //variables for POST request

   .success(function(data) {
         //Some Code
    }

    .error(function(status)){
         //Somo code
    }
 }

The thing is that I need to make five requests but I dont know how to call a function inside another function and also I need to pass two parameters to goRequest that are inside my toValues function $scope.merchMetric and $scope.topRank

        $scope.topValues = function () {

        $scope.value = "topCategories";

        $scope.newValue = function (value) {
            if (value == "topCategory") {
                $scope.merchMetric = $scope.topCat
                $scope.topRank="30"
                console.log($scope.merchMetric);
            } else if (value == "topSupplier"){
                $scope.merchMetric = $scope.topSupp;
                $scope.topRank="10"
                console.log($scope.merchMetric);
            } else if (value == "topBrand") {
                $scope.merchMetric = $scope.topBrand;
                $scope.topRank="10"
                console.log($scope.merchMetric);
            } else if (value == "topSubcategory") {
                $scope.merchMetric = $scope.topSubCat
                $scope.topRank="10"
            } else if (value == "topItem") {
                $scope.merchMetric = $scope.topItem
                $scope.topRank="20"
            }

        }

    }

So how can I call call the goRequest function inside my top values?

1 Answer 1

1

I don't really see what the problem is, you can just call a function inside another like any other time you call a function:

$scope.topValues = function() {
    someService.goRequest($scope.merchMetric, $scope.topRank);
}

If goRequest is inside the same controller you don't even have to pass on $scope.merchMetric and $scope.topRank, you can just read them from there.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank's fotr your time actually it's not like a big deal the thing is that I was not sure how to do this and also doing it in the Angular way. Im new to JS and Angular so I have a lot of questions so far :)
Thanks! actually they are in the same controller!

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.