-
Notifications
You must be signed in to change notification settings - Fork 27.4k
limitTo filter should have a left and right bound. #5355
Comments
you can do this by using it would be nice to have the api you are suggesting (except the second argument should be if you can work out the details and ensure that the api is not confusing we could consider it, especially if the code change required is tiny and someone from community submits a PR with tests and docs. |
it's easy to keep compatibility, you can do it like this
it's simply to change the logic to limit:left:length |
I'd like to suggest that to maintain current functionality the following be done. Leave the current first value as the
The only interesting caveat I can think of is that right now |
How about if the API were to match PHP's substr(...) method, which is well established AND supports negative values for both the 'start' and 'length' parameters in an intuitive way? |
why not a new "slice" filter ? shoule be more explicit, less confusing |
This creates a new filter that passes a string or array to native slice() method. This could be useful for pagination, because the limitTo filter only allows a limit, not a start and ending position. Creating a new filter is more intuitive and reflective of native Javascript rather than extending limitTo. angular#5355
This creates a new filter that passes a string or array to native slice() method. This is be useful for pagination or extracting a portion of a string or array. It differs from the limitTo filter because limitTo only has one bound, a starting position. Creating a new filter is more intuitive and reflective of native Javascript rather than extending limitTo. It should close issue angular#5355.
|
I'd agree with @revolunet about a new |
+1 for new slice filter, but here coms few questions. Should it follow: |
So, we should land some form of this simple but very often used filter. Reading through various issues / PRs opened for this topic I think that we've got few simple decisions to take:
My take would be to introduce a new Does anyone objects to the above plan? How do people feel about depreciating / removing the |
@pkozlowski-opensource Introduction of a new slice filter and leaving limitTo alone seems right to me |
@jlmagee the slight problem with leaving both |
Would love a new slice filter matching the JS API. I don't really like the idea of having redundant filters, so
|
Thnx for the input @mgcrea. Yup, there might be slight perf impact (one more function call), but not sure if it would matter in practice. The other idea of making it easier on people:
|
👍 for
|
removing |
@Jamm the current BTW: it would be really great if we could focus on the technical merits, pros & cons and tune down the language a bit - calling people irresponsible in the very moment when we are reaching out to the community for feedback sounds odd... |
@pkozlowski-opensource so add an argument and it will. If you want to add breaking change just because of naming - it's irresponsible. If you want to hear only positive feedback, without criticism - it's naive expectation. I'd glad to be less mean, but if we all will keep silence just to be "polite", breaking changes like this will ruin trust to Angular API at all. |
@Jamm not sure why are saying that this change is only about a name... The crux of the "problem" is that:
So the 2 are functionally related but not the same. Could you please elaborate what you mean by:
Are you referring to |
@pkozlowski-opensource but if you will add second argument to
yes, but it's not so important. I agree |
@Jamm ok, cool, I think I got all your answers to my previous questions. Thnx for the feedback! |
So basically, if I use |
Guys, we are leaning towards merging #10899 - if anyone is interested in this feature it is time to speak up now |
Woooohaaa! One of the most voted (and easiest to fix!) issues just got solved :-) |
👍 |
nice! it was my first contribution:) |
nice |
👍 |
Extend the limitTo filter to take an optional argument for beginning index. It provides a slice-alike functionality to manipulate the input. Closes angular#5355 Closes angular#10899
using like this:
{{'abcdefg' | limitTo:2:5}}
output:
cde
useful when paging sth..
The text was updated successfully, but these errors were encountered: