Hi, I believe you are looking for the $rollbackViewValue functionality that is built into angular. If this is the case there would not be a need for much custom js code.
See the example here: https://docs.angularjs.org/api/ng/directive/ngModelOptions Justin On Wednesday, 11 March 2015 16:08:07 UTC+2, KJ wrote: > > Hi, > > I have a input field which gets data from the database and is inside div > together with edit button next to it. > <input type="text" ng-model="user.value" /> > > When the user clicks on the edit button I show save and cancel button. > Clicking save calls service and saves data. > Now what if user edits values in the box and then clicks cancel that > should reset the box back to orginal state. > > I tried to add ng-click = "user.value='';" > > But this clears even the value that I bind from the db. How can reset the > box to previous state. > > Thanks > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
