Angular - save scope value to variable, but not update it when scope updates

Blejwi

I have something like this:

$scope.last_good_configuration = $scope.storage;

In $scope.last_good_configuration I keep last good settings.

And when user type in input bad value, for example too big integer i want to do:

$scope.storage = $scope.last_good_configuration;

But my $scope.last_good_configuration is all the time the same as $scope.storage. How to stop updating $scope.last_good_configuration? I have to evaluate my scope somehow?

Chris Charles

You need to make a copy or clone of the original object. Angular has a built in method for this: angular.copy.

$scope.last_good_configuration = angular.copy($scope.storage);


//Edits must be at least 6 characters workaround

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Update parent scope variable in AngularJS

From Java

Update scope value when service data is changed

From Dev

Angular scope doesn't update when removing an item

From Dev

Angular parent scope not updated when directive updates the same scope variable

From Dev

scope variable updates only the first time

From Dev

Update $scope when contenteditable Elements Change with Angular.js

From Dev

Angular.js - View doesn't update when changing a scope variable in resize event

From Dev

angular, pass a scope into a function (passing scope as variable?)

From Dev

Don't update HTML when angular $scope changes

From Dev

angular scope variable not binding

From Dev

How to update $scope immediately when dealing with non angular code?

From Dev

How variable scope of $scope in angular js works?

From Dev

Update scope value when service data changes

From Dev

Angular: update scope inside scope

From Dev

angular save/serialize $scope state

From Dev

angular update $scope variable inside loop

From Dev

Angular js animate on $scope variable update on <p> tag

From Dev

Scope value not updating when service variable changes

From Dev

Angular $scope variable not updating

From Dev

How to get dynamic view to update properly when scope variable changes

From Dev

Angular JS how to update scope variable inside another scope variable

From Dev

Angular.js - $scope.variable doesn't auto update

From Dev

what will be the scope of scope variable in link function in angular?

From Dev

angular watch - update variable outside function scope

From Dev

Update $scope when contenteditable Elements Change with Angular.js

From Dev

angular save/serialize $scope state

From Dev

How to update $scope variable value in AngularJs

From Dev

How to update Angular scope properties when they are passed into directives?

From Dev

Use a directive to display scope value and update scope

Related Related

  1. 1

    Update parent scope variable in AngularJS

  2. 2

    Update scope value when service data is changed

  3. 3

    Angular scope doesn't update when removing an item

  4. 4

    Angular parent scope not updated when directive updates the same scope variable

  5. 5

    scope variable updates only the first time

  6. 6

    Update $scope when contenteditable Elements Change with Angular.js

  7. 7

    Angular.js - View doesn't update when changing a scope variable in resize event

  8. 8

    angular, pass a scope into a function (passing scope as variable?)

  9. 9

    Don't update HTML when angular $scope changes

  10. 10

    angular scope variable not binding

  11. 11

    How to update $scope immediately when dealing with non angular code?

  12. 12

    How variable scope of $scope in angular js works?

  13. 13

    Update scope value when service data changes

  14. 14

    Angular: update scope inside scope

  15. 15

    angular save/serialize $scope state

  16. 16

    angular update $scope variable inside loop

  17. 17

    Angular js animate on $scope variable update on <p> tag

  18. 18

    Scope value not updating when service variable changes

  19. 19

    Angular $scope variable not updating

  20. 20

    How to get dynamic view to update properly when scope variable changes

  21. 21

    Angular JS how to update scope variable inside another scope variable

  22. 22

    Angular.js - $scope.variable doesn't auto update

  23. 23

    what will be the scope of scope variable in link function in angular?

  24. 24

    angular watch - update variable outside function scope

  25. 25

    Update $scope when contenteditable Elements Change with Angular.js

  26. 26

    angular save/serialize $scope state

  27. 27

    How to update $scope variable value in AngularJs

  28. 28

    How to update Angular scope properties when they are passed into directives?

  29. 29

    Use a directive to display scope value and update scope

HotTag

Archive