angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Add support for the input type=range

Open andybak opened this issue 12 years ago • 59 comments

Originally filed here: https://github.com/angular/angular.js/issues/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

andybak avatar Jan 20 '14 09:01 andybak

+1

mlegenhausen avatar Jan 20 '14 13:01 mlegenhausen

+1

ludoblues avatar Jan 22 '14 21:01 ludoblues

+1

adamnbowen avatar Feb 02 '14 19:02 adamnbowen

+1

kazekagegaara avatar Feb 09 '14 09:02 kazekagegaara

+1

ashclarke avatar Feb 10 '14 16:02 ashclarke

+1

marcelbuesing avatar Feb 13 '14 10:02 marcelbuesing

+1

vchirkov avatar Feb 20 '14 15:02 vchirkov

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.

lgarron avatar Mar 06 '14 22:03 lgarron

+1

mismith avatar Mar 07 '14 22:03 mismith

+1..

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

c9s avatar Mar 09 '14 16:03 c9s

+1

lcerveau avatar Mar 20 '14 13:03 lcerveau

+1

mlison avatar Mar 26 '14 11:03 mlison

+1

etamasdan avatar Apr 02 '14 17:04 etamasdan

+1

Bretto avatar Apr 03 '14 05:04 Bretto

+1

baleboy avatar May 06 '14 17:05 baleboy

+1

marcalj avatar Jun 26 '14 14:06 marcalj

+1

kunalnavhate avatar Jul 03 '14 06:07 kunalnavhate

+1

ezaelbello avatar Jul 15 '14 05:07 ezaelbello

+1

brunopaz avatar Aug 04 '14 08:08 brunopaz

+1

n1c avatar Aug 13 '14 13:08 n1c