Reputation: 1422
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?
Upvotes: 0
Views: 68
Reputation: 5605
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.
Upvotes: 1