angularjs - Capture the original value of an Angular model for in-place editing -


I have created a simple in-place editing solution for profile data in my app. The problem is, if a person Edits and modifies the text of that field, but due to the binding of the coonors, the change in text is still displayed in the UI to select "Cancel".

I was thinking that when someone "edits the profile", then I capture the original value of the ground so that if it is canceled, then it can restore the original text .

  $ scope.editProfile = - & gt; $ Scope.editState = true $ scope.originalDescription = $ scope.user.profile.description   

Of course, something that does not work is $ scope.user.profile.description at that time I want to edit when the Edit profile file is called.

Any suggestions for strategies here?

what you can do, is this:

  angular copy ($ Scope.user.profile.description, $ scope.description.backup)   

and if you need to restore the original values:

  Angular.copy ($ scope.description.backup, $ scope.user.profile description)    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -