Whenever a user submits a form, the fields are stored in a variable called $scope.params
. In order to keep track of all submitted data, I am attempting to save them in an object named $scope.history
. My current approach involves using the following code:
$scope.history.push($scope.params)
Unfortunately, this method is not working as expected. When I check the console output, it only displays the most recent values submitted by the form. For example, if I submit the form three times and change the "keywords" each time, the result looks like this:
{
{ keywords: 'Test 3' },
{ keywords: 'Test 3' },
{ keywords: 'Test 3' }
}
However, I was anticipating something more like this:
{
{ keywords: 'Test 1' },
{ keywords: 'Test 2' },
{ keywords: 'Test 3' }
}
How can I achieve the desired outcome?