Array.prototype.splice.apply($scope.timeSlots, [0, hoursAgo].concat(slots)); <div ng-repeat="timeSlot in timeSlots" class="time-slot">Hi Joberto,
If you do tricks like this to array’s you need a track by in your ng-repeat. and not on $index
You need to add this because of the way angular keeps track on where to put which element in the DOM
I suspect you have an id in the timeslots array? do something like this:
<div ng-repeat="timeSlot in timeSlots track by _id">
Regards
Sander
itaas.TimeSlot = function (start, end) {
this.schedules = [];
this.start = start;
this.end = end;
this.id = start.valueOf() + end.valueOf(); //needed for "ng-repeat track by id"
}; <div ng-repeat="timeSlot in timeSlots track by id" class="time-slot">var ids = _.pluck($scope.timeSlots,'id'); //[2826946800000, 2826954000000, 2826961200000, 2826968400000, 2826975600000, 2826982800000]
_.uniq(ids) //[2826946800000, 2826954000000, 2826961200000, 2826968400000, 2826975600000, 2826982800000]Hi Joberto,
Sorry, I missed a little subtle part :-D
try this:
<div ng-repeat="timeSlot in timeSlots track by timeSlot.id" class="time-slot">
Sorry for the confusion
Regards
Sander
Array.prototype.splice.apply($scope.timeSlots, [0, 2].concat(earlier));Array.prototype.splice.apply($scope.timeSlots, [0, 0].concat(earlier));