Previously, I was able to retrieve the initial values of the model using this.model.changed
or this.model._previousAttributes
in BackboneJS.
Now, I am looking to achieve the same functionality in AngularJS, where I can track all changes made to the model through text fields and checkboxes, not just a single text field like with ng-change
.
I have attempted to incorporate this within a form
div without success.
I also experimented with:
$scope.policyL = savingsDraft.fromServer();
$scope.$watch('policyL', function (oldV, newV) {
});
Unfortunately, this approach did not yield the desired result either.
Here is an example snippet from my view code:
form(role='form', ng-change='changed (policy, newP)' novalidate)
.row
.col-sm-4.form-group
label.control-label Taux de rendement
input.form-control(type='number',
min=0,
max=1,
ng-model='policy.admin.depEarnRate')
.col-sm-4.form-group
label.control-label Frais de contrat
input.form-control(type='number',
min=0,
ng-model='policy.admin.feesIni')
And in my controller:
$scope.accept = function () {
$scope.change = function();
};
PS: My ultimate goal is to retrieve the original model data after clicking on the accept button.