Khilen Maniyar
Khilen Maniyar

Reputation: 2579

Angular: Make a copy of actual data not working

On API Success response. I'm trying to make a copy of data but on $scope change it gets affected too. I'm Working with Angular Component structure project.

Example

var actualData = $scope.data;
var workingData = $scope.data;

Now later on in project if workingData changes, it also changes actualData.

Thanks.

Upvotes: 0

Views: 187

Answers (1)

Manu Obre
Manu Obre

Reputation: 2304

You could use angular.copy(source, [destination]) to make a deep copy of the original object.

angular.copy(actualData,workingData)

Upvotes: 1

Related Questions