Drigger_1618 Drigger_1618 - 1 year ago 63
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.

Answer Source

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

Please refer the link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download