0

In the code below I have an object named $scope.dateRange with property fromDate and toDate. I used the object at view as model, and I am updating the values of the objects at GetVoucherLatestDate() function. But it is not updating, it is remain as null that I have declared before the function, because it is asynchronous.

What I need is to get the dates value from the function to show in the view during the page load? I need the help desperately.

$scope.dateRange = {
    fromDate: null,
    toDate: null
};
$scope.gap = -2;
$scope.budgetResponsiblePersonId = null;
$scope.overAllStatusList = [];
console.log("DatePre", $scope.dateRange);
$scope.GetVoucherLatestDate = function () {
    $http({
        method: 'GET',
        url: 'Accounts/MISAccountDashboard/GetVoucherLatestDate/',
        dataType: 'JSON'
    }).then(function successCallback(response) {
        $scope.getFromDate = response.data;
        console.log("Response Data", response.data);
        console.log("$scope.data", $scope.getFromDate);
        dateData = ;       
        $scope.dateRange = {
            fromDate: $filter('dateFiltering')($scope.getFromDate[0].PostingDate, 'dd-MMM-yyyy'),
            toDate: $filter('dateFiltering')($scope.getFromDate[0].PostingDate, 'dd-MMM-yyyy')
        };
    });

};
$scope.GetVoucherLatestDate();
StaticVariable
  • 396
  • 2
  • 10
Abdullah Al Mamun
  • 392
  • 1
  • 4
  • 13

1 Answers1

0

I am not sure how you have bind the model in UI, however $scope.$apply() should propagate your changes to UI.

TBA
  • 1,077
  • 5
  • 41
  • 80