Reputation: 23
branchAccess.pendingList[i]
object loosing other properties like it had.
branchAccess.pendingList[i].testMyAccessStatus
its undefined
after assigning newly added. can we use angular.copy
or angular.clone
to keep the object with its existing properties and also add a newly created object accessStatusDetails
?
This is my code:
this.selectAll = function(branchAccess) {
//checking if undefined
var accessStatusDetailsAdd = {
accessStatusDetails : { accessStatus : "A" }
}
if(branchAccess.pendingList[i].accessStatusDetails == undefined){
branchAccess.pendingList[i] = accessStatusDetailsAdd;
}
}
Upvotes: 0
Views: 29
Reputation: 1136
Check angular.extend() function
var object1 = {
"color": "yellow",
}
var object2 = {
"animal": "horse",
}
var mergedObject = angular.extend(object1, object2);
// mergedObject = {
// "color": "yellow",
// "animal": "horse"
// }
Upvotes: 1