function dialogController(generate, $scope) {
$scope.profiles = generate.get_keys('::role');
$scope.content = {};
$scope.options = [];
$scope.servers = {};
$scope.subs = {};
$scope.discountList = {};
$scope.total = {};
$scope.toggle = function(item, list) {
var idx = list.indexOf(item);
if (idx > -1) {
list.splice(idx, 1);
} else {
list.push(item);
}
};
$scope.contentList = function(name) {
$scope.content = generate.get_config('::role::' + name).items;
// console.log($scope.content);
};
$scope.priceMapping = function(subscriptionPrice) {
var obj = {
'bronze': [129, 0.5],
'silver': [165, 0.5],
'gold': [199, 1],
'platinum': [265, 1]
};
return obj[subscriptionPrice];
};
$scope.calculatePrice = function() {
angular.forEach($scope.options, function(opt) {
$scope.discountList[opt] = {};
$scope.discountList[opt].servers = $scope.servers[opt];
$scope.discountList[opt].subscription = $scope.subs[opt];
var price = (Math.pow($scope.servers[opt], 0.75)) * $scope.priceMapping($scope.subs[opt])[0];
console.log(price);
var hours = Math.round((($scope.priceMapping($scope.subs[opt])[1]) * (Math.pow($scope.servers[opt], 0.75))) * 10) / 10;
console.log(hours);
$scope.discountList[opt].price = price;
$scope.discountList[opt].hours = hours;
});
var totalPrice = 0;
var totalHour = 0;
};
}
Here I want to calculate total price and total hours using angular for each. Prices and hours are present in discountList{}.
How could I calculate total price and total hours?
discountList{} contains price and hours so how could I calculate the total of them?