Didn't know we could use any property in the *track by*.
I didn't have an *id* property, but I've created one:
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"
};
And
<div ng-repeat="timeSlot in timeSlots track by id" class="time-slot">
However, it is throwing ng-repeate dupes error.
There isn't a duplicate id:
var ids = _.pluck($scope.timeSlots,'id'); //[2826946800000, 2826954000000,
2826961200000, 2826968400000, 2826975600000, 2826982800000]
_.uniq(ids) //[2826946800000, 2826954000000, 2826961200000, 2826968400000,
2826975600000, 2826982800000]
Any thoughts?
On Thursday, October 16, 2014 11:26:39 AM UTC-3, Sander Elias wrote:
>
> 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
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.