angularjsangularjs-ng-model

AngularJs: model object gets converted to an array


I am seeing a weird issue and spending unfruitful time.

In my controller I have an object declared as

$scope.brfdet = { iJobId: $scope.job.iJobId, iAppType: null, dEarlyShipmentDate: null, dStockdate: null, dFromDate: null, dToDate: null};
console.log('$scope.brfdet: ', $scope.brfdet);

The console log shows it correctly as this:

$scope.brfdet: { iJobId: 3245, iAppType: null, dEarlyShipmentDate: null, dStockdate: null, dFromDate: null, dToDate: null};

However, just before I submit the data, I see that the value of variable as below.

$scope.brfdet: [dFromDate: "01/01/2020", dToDate: "01/01/2021", iAppType: "1"]

I'm clueless why this is happening. Please help.

UPDATE:

I could figure it out. The $scope.brfdet was getting set to an empty array in an AJAX call - a fault in the API.


Solution

  • It looks like that something else is linked to $scope.brfdet. Is it used anywhere else (e.g. in a view)? How do you submit the data? What is happen in your code between "console log" output and submit?