I've the following controller in AngularJS:
$scope.model = null;
$scope.load = function() {
$http.get(someUrl).success(function (data) {
$scope.model = data;
}
}
$scope.save = function() {
$http.post(url, $scope.model)
.success(function (data) {
// some handle
}).error(function () {
// some handle
});
}
The model scheme:
$scope.model.PayDate === "2015-04-29T22:00:00.000Z"
// deserialized from request, date is in ASP.NET format
Next, the PayDate
prop is attached to some control (via ng-model
), that sets the new date in javascript DateTime class.
So, the value of changed PayDate
before sending to the server looks like:
Unfortunately, when request is sent to the server, the value of PayDate
is the old one:
Why the old value of PayDate
is sent instead of current stored in the model?
EDIT: The workaround is to convert JS date to string before send:
$scope.model.PayDate = moment($scope.model.PayDate ).format("YYYY-MM-DD");
$scope.save();
Then, new value is send in a request.
Of course, I would like to fix the issue instead of converting each date field into string just before posting.