0

I just wanted to know is there any way to bind variables without bind each other.

     this.commissions = res.Data;
     this.oldCommissions = res.Data;

When I changed a 'Price' value of this object this.commissions

this.oldCommissions also change 'Price' value.

How can I avoid this is anybody knows that?

2 Answers 2

1
 this.commissions =angular.copy(res.Data);
 this.oldCommissions =angular.copy(res.Data);
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, this is what I want. Actually this is for Angular v1.x but I'm using Angular v2.x, there optional solutions for it. thanks
0

I am guessing you want to try angular's deep copy funtionality where both variables do not point to the same index. Please find link for the same - https://docs.angularjs.org/api/ng/function/angular.copy#!

1 Comment

I would also post the code but @Alireza already beat me to it :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.