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

feat(limitTo): Add support for numbers in limitTo #8926

Closed
wants to merge 1 commit into from

Conversation

hjast
Copy link

@hjast hjast commented Sep 4, 2014

It would be nice if limitTo supports numbers. The expected behavior would change input to string and just run limitTo on that value. This becomes useful often when you have long decimal numbers, etc...

@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@hjast
Copy link
Author

hjast commented Sep 4, 2014

I have signed the CLA. Let me know if there is anything else I need to do.

@shahata
Copy link
Contributor

shahata commented Sep 4, 2014

You mean like this? http://plnkr.co/edit/iwmnK1NB5KgFNfodeINk?p=preview
It already works...

@shahata
Copy link
Contributor

shahata commented Sep 4, 2014

Ah, forget about it. I didn't understand your comment at first.

@hjast
Copy link
Author

hjast commented Sep 4, 2014

@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@shahata
Copy link
Contributor

shahata commented Sep 4, 2014

So why not use https://docs.angularjs.org/api/ng/filter/number?

@@ -17,6 +19,8 @@ describe('Filter: limitTo', function() {
expect(limitTo(items, '3')).toEqual(['a', 'b', 'c']);
expect(limitTo(str, 3)).toEqual("tuv");
expect(limitTo(str, '3')).toEqual("tuv");
expect(limitTo(number, 3)).toEqual("100");
expect(limitTo(number, '3')).toEqual("100");
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation

@caitp
Copy link
Contributor

caitp commented Sep 4, 2014

I don't totally understand the use-case, but it looks basically okay to me --- just clean up the indentation and commit messages and squash (see https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit). I'll see what people think about this today I guess

@caitp caitp added this to the 1.3.0 milestone Sep 4, 2014
@hjast
Copy link
Author

hjast commented Sep 4, 2014

Awesome will do!

My use case was for numerical values which you do not want to format with commas and/or for non-homogenous data sets (which have either a string or a number). For example barcode or ssn or id, etc....

hjast added a commit to hjast/angular.js that referenced this pull request Sep 4, 2014
feat (limitTo) : Add support for numbers in limitTo

Added support for numbers as input in limitTo filter :
- Will treat number as a string and limit number of places shown.

Closes angular#8926
@hjast
Copy link
Author

hjast commented Sep 4, 2014

Squashed and committed with appropriate messaging. I am getting some strange errors on the TravisCI only in regards to jqlite (tests pass locally) -> Timed out waiting for Protractor to synchronize with the page after 0 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md.

I can work on fixing this, but wanted to know if what people thought (so I don't take up time if it is a feature that people are against). Look forward to hearing your thoughts.

@caitp
Copy link
Contributor

caitp commented Sep 4, 2014

Don't worry about the timeout, it's just flakes, most likely (will take a look). The commit message however still does not follow the message guidelines

hjast added a commit to hjast/angular.js that referenced this pull request Sep 4, 2014
Added support for numbers as input in limitTo filter :
- Will treat number as a string and limit number of places shown.

Closes angular#8926
@hjast
Copy link
Author

hjast commented Sep 4, 2014

Sorry, had added the subject in the body. Fixed it.

@hjast hjast changed the title Update limitTo to support numbers feat(limitTo): Add support for numbers in limitTo Sep 4, 2014
@@ -72,6 +72,7 @@
*/
function limitToFilter(){
return function(input, limit) {
if (typeof input == "number") input = input.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

should use isString

wait nvm, misread that

Copy link
Contributor

Choose a reason for hiding this comment

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

isNumber(), yeah

hjast added a commit to hjast/angular.js that referenced this pull request Sep 4, 2014
Added support for numbers as input in limitTo filter :
- Will treat number as a string and limit number of places shown.

Closes angular#8926
@@ -72,6 +72,7 @@
*/
function limitToFilter(){
return function(input, limit) {
if (isNumber(input)) input = input.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

this PR is missing the type signature / doc update

hjast added a commit to hjast/angular.js that referenced this pull request Sep 4, 2014
Added support for numbers as input in limitTo filter :
- Will treat number as a string and limit number of places shown.

Closes angular#8926
hjast added a commit to hjast/angular.js that referenced this pull request Sep 4, 2014
Added support for numbers as input in limitTo filter :
- Will treat number as a string and limit number of places shown.

Closes angular#8926
Added support for numbers as input in limitTo filter :
- Will treat number as a string and limit number of places shown.

Closes angular#8926# Please enter the commit message for your changes. Lines starting
@hjast
Copy link
Author

hjast commented Sep 5, 2014

I have added documentation and end to end tests. Please let me know if what I added suffice. Thanks!

@btford
Copy link
Contributor

btford commented Sep 10, 2014

landed as 1c8a745. Thanks!

@btford btford closed this Sep 10, 2014
btford pushed a commit that referenced this pull request Sep 10, 2014
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.

None yet

6 participants