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



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

i built simple in-place editing solution profile info in app. problem is, if edits field , modify text of field take "cancel," instead of save, because of angular's bindings, text alter still displayed in ui.

i thinking when "edit profile," capture original value of field if nail cancel, restore original text.

$scope.editprofile = -> $scope.editstate = true $scope.originaldescription = $scope.user.profile.description

of course, doesn't work. want capture $scope.user.profile.description @ time editprofile function called.

any suggestions strategies here?

what can do, is:

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

and if need restore original values:

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

angularjs

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -