Store binded object before change

I have an object which contains information on a group:

selectedGroup:  { 
      name: Test Group,
      id: 10,
      description: a group,
      owner: 88,
      ownerIsUser: False
 }

I have textbox which binds to the selectedGroups.name property. I need to store that name in it's own variable before a change occurs.

I have an AJAX library that allows me to update the groups info like name and description but it needs the old name to identify which group to update. I tried:

var oldName = selectedGroup.name

But this doesn't work since as soon as I start typing something oldName gets updated.

Answers


You can create a watch:

$scope.$watch('selectedGroup.name', function(newVal, oldVal) {
   // save/copy oldVal somewhere 
});

PD: To deep copy the object you can use angular.copy()


Need Your Help

hadoop 1.x ports list - 4 more unknown ports

hadoop networking mapreduce hdfs

I configured and installed hadoop 1.2.1 single node. I configured the namenode and jobtracker address with ports as "hdfs://localhost:9000" and "localhost:9001" respectively.

How to resize images in org-mode

html image resize export org-mode

Is there a general way to define the size, in percent or pixels, for an image that is linked in org-mode?