When you create a new object, you assign a hardcoded index value of "abc" to each object.
var abc = 0;
$scope.addNode = function(){
abc++;
var addObj = {name:"name"+abc, index:abc};
$scope.sitemap.push(angular.copy(addObj));
}
Subsequently, when you remove an object, you use this hardcoded index value in the function.
$scope.removeNode = function(index){
$scope.sitemap.splice(index,1);
}
For instance, if you have the following array:
obj1 - hardcoded index 0 - array index 0
obj2 - hardcoded index 1 - array index 1
If you remove obj1 from array with index 0, obj2 will take its place at index 0 in the array, like so:
obj2 - hardcoded index 1 - array index 0
However, even though the actual index has changed, you are still passing index 1 to the removeNode function as it was created with that value.