I have an object attached to $scopewhich I want to serialize to JSON. The object was configured with data binding, so there are input fields using ng-modeland what not. When you try to call the angular.toJsonvalues are not updated.
It is strange that I realized that my values were not updated as I thought. So I launched some calls console.logfor simplicity, but the values from console.logare correct, but they are not for JSON conversion? I tested it with JSON.stringify, but the results were the same. The code:
console.log('Data:', $scope.obj);
var temp = angular.toJson($scope.obj);
console.log('Data:', $scope.obj);
console.log('Data:', temp);
Is this the Angular issue I am facing that is related to data binding? Or is something else going on?