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 #1189

Closed

Description

@leijou

With multiple inputs to the same model <input type="number" /> 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. pkozlowski-opensource commented on Dec 16, 2012

    @pkozlowski-opensource
    Member

    The behavior of the number input type is correct. What could be done here is to add support for the range input type (so it converts results to a number like the number input type).

    Even if browsers support for the range isn't great (http://caniuse.com/#search=range) still people would mostly expect a number from the input type range.

  2. metamatt commented on Apr 24, 2013

    @metamatt
    Contributor

    I agree; I would expect input(type=range) to yield a number in its ngModel. Thanks for working on this.

  3. btford commented on Aug 24, 2013

    @btford
    Contributor

    As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

    Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

    Thanks!

  4. TylerEich commented on Nov 23, 2013

    @TylerEich
    Contributor

    As of v1.2.1, the issue persists

  5. mlegenhausen commented on Dec 3, 2013

    @mlegenhausen

    Same in v1.2.3.
    There is no conversion done from type string to number which should be the expected behaviour.
    Please reopen.

  6. nickretallack commented on Dec 9, 2013

    @nickretallack

    I just ran up against this problem. Very frustrating.

  7. stanleygu commented on Jan 13, 2014

    @stanleygu

    I encountered this issue where the slider toggle becomes stuck at 0 or 100 if the model is outside that range.

  8. andybak commented on Jan 20, 2014

    @andybak

    It looks like closed tickets are never looked at again so asking nicely to reopen doesn't work. I've reposted this issue here: #5892

  9. added a commit that references this issue on May 6, 2014
    66d0419
  10. Virupax commented on Dec 16, 2015

    @Virupax

    div ng-app ng-controller="Ctrl">
    Range:

    Text:

    Select: 00.5 11.5 22.5 33.5 44.5 5

    Number:



    i: {{i}}

    function Ctrl($scope) {
    $scope.i=4;
    $scope.$watch('i', function() {
    //$scope.i = parseInt($scope.i);
    });
    }

    Just change it to parseInt();

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions