If I have the following object $scope.object1
which looks something like this:
{
"firstName": "Name"
"lastName": "Name"
"startingDate": "08/Nov/2016"
"endingDate": "16/Dec/2016"
"description": "asd"
}
And I have a form which takes those values from backend and uses them on the input fields for date and description.
The fields are editable so changing startingDate
in the form field will change starting date in object1
.
I need to display some content based on the initial values of $scope.object1
are the same with the values after submitting the form.
With other words, if nothing has changed.
How can I save the initial values of object1
and compare them with the values after modifying the form?
You can use
angular.copy()
to store the object before it is edited andangular.equals()
to compare it with the modified version after it is edited