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

Add support for the input type=range #5892

Closed

Description

@andybak

Originally filed here: #1189

(This was incorrectly closed and despite requests to reopen, has remained closed so I'm reposting as a new ticket. For future reference, closing old tickets due to lack of activity is probably not a good idea.)

With multiple inputs to the same model doesn't play ball. It works as an input but updating it to a value set from another input always fails. Even if the source is also constrained as numeric (type="range" in chrome). This is due to the model being stored as a string.

Demo: http://jsfiddle.net/TXazw/5/Edit
Edit any input except the number and everything updates except the number input. Edit the number input and everything works fine.

A workaround is included. Uncomment parseFloat line and all inputs work correctly.

Should values not be automatically parsed when applied to a number type input? At the very least type="range" should be outputting a number rather than a string.

Discussed in the group:
https://groups.google.com/forum/?fromgroups#!topic/angular/Ecjx2fo8Qvk

Activity

  1. mlegenhausen commented on Jan 20, 2014

    @mlegenhausen

    +1

  2. ludoblues commented on Jan 22, 2014

    @ludoblues

    +1

  3. adamnbowen commented on Feb 2, 2014

    @adamnbowen
    Contributor

    +1

  4. kazekagegaara commented on Feb 9, 2014

    @kazekagegaara

    +1

  5. ashclarke commented on Feb 10, 2014

    @ashclarke

    +1

  6. marcelbuesing commented on Feb 13, 2014

    @marcelbuesing

    +1

  7. vchirkov commented on Feb 20, 2014

    @vchirkov

    +1

  8. lgarron commented on Mar 6, 2014

    @lgarron

    Indeed. It sounds petty, and it's probably easy to learn how to write a directive to fix this by passing through parseFloat(), but it's kind of annoying that a binding for input[type=range] is a string instead of a number.
    Even if Javascript sometimes uses strings where something else would be suited better, this breaks the principle of least surprise, and has already caused me to create bugs.

    Most use cases of input ranges will expect/need a number, and it's not terribly inefficient to support that.

  9. mismith commented on Mar 7, 2014

    @mismith

    +1

  10. c9s commented on Mar 9, 2014

    @c9s

    +1..

    It should have something like ns-type="integer" or ns-type="float"

  11. lcerveau commented on Mar 20, 2014

    @lcerveau

    +1

  12. mlison commented on Mar 26, 2014

    @mlison

    +1

  13. added this to the milestone on Mar 27, 2014
  14. 49 remaining items

  15. westonganger commented on Jan 1, 2016

    @westonganger

    +1

  16. FLHerne commented on Feb 3, 2016

    @FLHerne

    +1.

    Just traced a weird-looking bug to this - in a language where ("7" + 3) * 10 is 730, having obviously-numeric values be strings is just asking for sensible-looking code to produce insane values.

  17. tayloj commented on Feb 17, 2016

    @tayloj

    +1

  18. ohcrfpv commented on Apr 20, 2016

    @ohcrfpv

    +1

  19. modified the milestones: 1.5.x, on Jun 15, 2016
  20. dennybiasiolli commented on Jul 5, 2016

    @dennybiasiolli

    +1

  21. added 2 commits that reference this issue on Jul 5, 2016
    58073f8
    94612d6
  22. added 2 commits that reference this issue on Jul 29, 2016
    1001d76
    807622e
  23. added 2 commits that reference this issue on Jul 29, 2016
    9130166
    296da4b
  24. sbaechler commented on Jul 5, 2017

    @sbaechler

    To summarize:
    The bug has been fixed in version 1.5.9. But for it to work you have to add the attribute ng-input-range to the input[type=range] element. This is not necessary for Angular.js 1.6.

    https://code.angularjs.org/1.5.9/docs/api/ng/input/input%5Brange%5D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions