Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(ngRepeat): add $prev and $next #11948

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nswbmw
Copy link

@nswbmw nswbmw commented May 27, 2015

In some cases, i need to get previous element before this $index or get next element after this $index. Array works well, but Object not. Maybe others need this feature too.

@@ -302,6 +304,8 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
// jshint bitwise: false
scope.$odd = !(scope.$even = (index&1) === 0);
// jshint bitwise: true
scope.$prev = prev;
scope.$next = next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I can understand why you'd want this feature, but we do see a real performance impact from adding properties to each scope, it's not ideal. I think we need to be very careful about adding new ones

@gkalpak
Copy link
Member

gkalpak commented May 27, 2015

Just adding a little context:

There's been a couple of similar PRs already (e.g. #9795, #10362).

IIRC, it was discussed during the planning meeting for 1.4.
IIRC again, people (@IgorMinar ?) weren't too keen on adding new properties on all ngRepeat generated scopes, but there were some interesting alternatives discussed (e.g. adding them on-demand, having a getter property that caclulates them only if they are requested (by @lgalfaso ?)).

I am not sure what the final verdict was (some memory, huh ?) 😃

@Narretz
Copy link
Contributor

Narretz commented May 28, 2015

I think the consensus was to add the extra properties on-demand. But we didn't really work on it.

@Narretz Narretz added this to the Purgatory milestone May 28, 2015
@gkalpak gkalpak modified the milestones: Ice Box, Purgatory Jun 2, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants