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

feat(ngRepeat): support a new range syntax for integer arrays #5557

Closed
wants to merge 2 commits into from

Conversation

gsklee
Copy link
Contributor

@gsklee gsklee commented Dec 28, 2013

Provide a range syntax [from..to] as a shorthand when iterating over an array of integers.

Closes #3861
Closes #5268


The refactoring commit has been wrapped independently as a separate PR (#5556).

@ghost ghost assigned matsko Dec 31, 2013
@IgorMinar
Copy link
Contributor

this looks neat at first sight but I think that there are other ways to achieve the same thing without making ngRepeat syntax more complicated and with it making the implementation also more complicated.

Take a look at
http://stackoverflow.com/questions/11873570/angularjs-for-loop-with-numbers-ranges

@gsklee
Copy link
Contributor Author

gsklee commented Jan 1, 2014

@IgorMinar That looks interesting but feels a little bit weird; official filters we've got so far are either a bijection or a surjection, but the linked solution makes it look like it's creating a range of something out of nowhere. Would look better if it's called something like append or push or fill.

So to summarize, a generalized filter solution would give us n in [] | fill: from: to, which IMHO is less concise than the n in [from..to] this PR offers. If you're okay with that then I can make a separate PR with the new filter.

@IgorMinar
Copy link
Contributor

what about a solution like this: ng-repeat="n in range(5,15)" doesn't that work sufficiently well for you?

@gsklee
Copy link
Contributor Author

gsklee commented Jan 5, 2014

I was able to cut the number of $eval from 3 to 1, but if it is possible to pass the local into $watchCollection directly then the last one can be ditched as well to gain better performance. I can open a separate issue and work on it if you think this is a good idea.

A tiny refactor to make the codeflow more fluent by following the order of the expression.
@gsklee
Copy link
Contributor Author

gsklee commented Jan 5, 2014

Any way to re-trigger the Travis building process? It failed but it's not my fault 💩

ERROR [launcher]: internet explorer 9 (Windows 2008) on SauceLabs failed 2 times (timeout). Giving up.

@matsko
Copy link
Contributor

matsko commented Jan 5, 2014

@gsklee just do commit --amend and push ORIGIN BRANCH -f

Provide a built-in `$range(_from_, _to_)` function as a shorthand method to quickly iterate over an array of integers.

Closes angular#3861
Closes angular#5268
Closes angular#5557
@gsklee
Copy link
Contributor Author

gsklee commented Jan 6, 2014

@matsko that worked - thanks 😸

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants