This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ngRepeat): expose $first, $middle and $last instead of $position
$position marker doesn't work well in cases when we have just one item in the list because then the item is both the first and last. To solve this properly we need to expose individual $first and $middle and $last flags. BREAKING CHANGE: $position is not exposed in repeater scopes any more To update, search for $position and replace it with one of $first, $middle or $last. Closes #912
- Loading branch information
Showing
2 changed files
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1d38867
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to namespace all 4 of the variables? like $repeatParam={
index:"",
first:true,
middle:true,
last:true
}
1d38867
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that might be a bit too verbose. Compare
<li ng-class="{first: $repeatParam.first, last: $repeatParam.last}"></li>
to
<li ng-class="{first: $first, last: $last}"></li>
Although the namespace could be shorter, like
$ng.first
or$repeat.first
, I think that just having the dollar sign prefix in front of first/middle/last/index is enough to not accidentally cause a conflict with any of the user's own variables.