I want to use var
variable in scope. How can I do like this: $scope.jsondata.var
In this example I want to use datePeriod
variable in $scope.myData[index].daily
so $scope.myData[index].datePeriod
in controller.
Note: daily
is a json data element. It's changes daily, weekly, monthly.
var datePeriod = $scope.datePeriod;
$http.get("reports?type="+datePeriod).then(function(response) {
$scope.myData = response.data;
angular.forEach($scope.myData, function(value, index) {
dailyData.push({
y: $scope.myData[index].daily,
a: $scope.myData[index].TOTAL_CIRO,
b: $scope.myData[index].DELIVERY_TOTAL
});
console.log(datePeriod);
});