Although my question may seem similar to others, it is unique!
Please review to understand my specific situation.
I am dealing with an array of objects that looks like this
$scope.events =[
{
$$hashKey: "009"
_allDay:false
_id:5
allDay:false
className:[]
end:Date {Fri Aug 08 2015 12:30:00 GMT+0530 (IST)}
start:Date {Fri Aug 08 2015 12:30:00 GMT+0530 (IST)}
title:"Birthday Party"
},
{
$$hashKey:"006"
_id:2
end:Date {Wed Aug 05 2015 00:00:00 GMT+0530 (IST)}
start:Date {Sun Aug 02 2015 00:00:00 GMT+0530 (IST)}
title:"Long Event"
},
{
$$hashKey:"007"
_id:3
allDay:false
id:999
start:Date {Fri Aug 07 2015 13:00:00 GMT+0530 (IST)}
title:"Angular Event"
},
{
$$hashKey:"008"
_id:4
allDay:false
id:999
start:Date {Tue Aug 11 2015 16:00:00 GMT+0530 (IST)}
title:"Repeating Event"
},
{
$$hashKey:"00A"
_id:6
end:Date {Sat Aug 29 2015 00:00:00 GMT+0530 (IST)}
start:Date {Fri Aug 28 2015 00:00:00 GMT+0530 (IST)}
title:"Click for Google"
}
]
Now my task is to remove an object from this array, which looks like this
var selectedObj = {
$$hashKey:"009"
_allDay:false
_id:5
allDay:false
className:[]
end:Date {Fri Aug 07 2015 12:30:00 GMT+0530 (IST)}
start:Date {Fri Aug 07 2015 12:00:00 GMT+0530 (IST)}
title:"Birthday Party"
}
My approach to removing the object is as follows
removedArray = _.reject($scope.events, function(event) {
return event.$$hashKey == selectedObj.$$hashKey
});
$scope.events = removedArray;
$scope.events
does not update even after trying $apply
.
Could someone assist me in identifying any mistakes I may have made?
What would be the best practice for handling such issues?