Drigger_1618 Drigger_1618 - 4 months ago 32
AngularJS Question

How to create a new instance of variables in AngularJs so that their values would be independent of the original one?

I am trying to populate a field in a map with a another map from a list of pre-defined maps. I am using the following code to do so.

$scope.addField = function(parentIndex,fieldIndex){



And I am using the parentMapList as ng-models in the view. But whenever I edit one of the fields in one of the map. It automatically edits an another field of the same category in another map.

How do I decouple/remove the binding between them ? Is there a possibilty to create a new instance everytime I try to copy one of the fields into another in angularJS.


Use var data= angular.copy($scope.parentMapList);

Please refer the link