function GetAllPrintSalesRecord() {
const urlParams = new URLSearchParams(window.location.search);
const OrderNo = urlParams.get('OrderNo');
.then(function (response) {
var data = response.data.modifiedData;
$scope.PrintSalesRecordList = data;
$scope.OrderDate = response.data.OrderDate;
$scope.Total = response.data.total;
$scope.DiscountTotal = response.data.discount;
$scope.VatTotal = response.data.tax;
if ($scope.$$phase) {
$scope.$apply();
}
Loading

Vishal JoshiRank #377 · 6.7K reputationPosted Feb 9, 2024, 12:38 AM EST
Hello,
You need to check bindings. as per the code you have bind the data in data variable and still in OrderDate trying to bind data from response model.
Try the below code to get the Date:
function GetAllPrintSalesRecord() { const urlParams = new URLSearchParams(window.location.search); const OrderNo = urlParams.get('OrderNo'); .then(function (response) { var data = response.data.modifiedData; $scope.PrintSalesRecordList = data; $scope.OrderDate = data[0].OrderDate; $scope.Total = response.data.total; $scope.DiscountTotal = response.data.discount; $scope.VatTotal = response.data.tax; if ($scope.$$phase) { $scope.$apply(); }Thanks
Vishal Joshi
Jayraj ChhayaRank #304 · 8.2K reputationPosted Feb 9, 2024, 12:39 AM EST
you can follow these steps:
Check the response from the server: Make sure that the server is sending the correct data for the
OrderDatefield. You can use browser developer tools or console.log to inspect the response and verify that theOrderDatevalue is present and in the expected format.Verify the data binding: Ensure that the
$scope.OrderDatevariable is correctly bound to the date value in the HTML template. Double-check the variable name and make sure it matches the one used in the template.Check for any errors or exceptions: Look for any error messages or exceptions in the browser console that might be preventing the date from being displayed. Address any errors or exceptions that you find.
Verify the HTML template: Check the HTML template where the receipt header is defined. Make sure that the
OrderDatevariable is correctly referenced in the template using AngularJS's data binding syntax, such as{{ OrderDate }}.Test with sample data: If the above steps do not resolve the issue, try hardcoding a sample date value directly in the controller and see if it appears in the receipt header. This will help determine if the issue is with the data or the code logic.
Amit MohantyRank #112 · 20K reputationPosted Feb 9, 2024, 1:05 AM EST
Check the values of response.data.OrderDate and other variables to ensure they contain the expected values by using console.log.
You can directly apply changes to the scope using $scope.$apply() without conditionally checking $scope.$$phase.
You might need to format response.data.OrderDate by using AngularJS filters or JavaScript Date functions, if it is not in correct format.
.then(function (response) { var data = response.data.modifiedData; $scope.PrintSalesRecordList = data; $scope.OrderDate = new Date(response.data.OrderDate); // Convert to Date object $scope.Total = response.data.total; $scope.DiscountTotal = response.data.discount; $scope.VatTotal = response.data.tax; $scope.$apply(); })Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Feb 10, 2024, 11:13 AM EST
Thank you team, please it is working now