|How to two-way bind a int value?||Meow||1/15/13 7:28 PM|
I'm trying to bind an integer value to an input element.
But I got this:
I'm using Web UI 0.2.11 and Dartium 25.0.1364.0 (173683) in checked mode.
I could write a wrapper for myInt, but my actual code involves properties of multiple objects. Should I wrap all of these?
So, what is the correct way to declare two-way bindings with integer values? Or should I wait until something like transforms or converters to be implemented?
|Re: How to two-way bind a int value?||John Messerly||1/15/13 7:53 PM|
On Tue, Jan 15, 2013 at 7:28 PM, Meow <shyc...@gmail.com> wrote:I'm trying to bind an integer value to an input element.
This should work:
I think the issue here is that the DOM property InputElement.value is a String, whereas InputElement.valueAsNumber is a num (there's also valueAsDate if you want a Date).
|Re: How to two-way bind a int value?||Meow||1/16/13 4:58 AM|
It works only in theory, I'm afraid.
I checked the generated code for bind-value-as-number. It calls .valueAsNumber when getting the value, but set .attributes['valueAsNumber'] when watchers are dispatched (instead of .valueAsNumber as expected).
As a result, the value never gets displayed on the input element.
|Re: How to two-way bind a int value?||Seth Ladd||1/21/13 10:45 AM|
Indeed, I tried this and I couldn't get it to work. I filed https://github.com/dart-lang/web-ui/issues/317 to track.
For the record, when I tried to bind to a variable annotated as an int, I got:
Exception: type 'double' is not a subtype of type 'int' of 'myInt'.
Stack Trace: #0 init_autogenerated.<anonymous closure> (http://127.0.0.1:3030/Users/sethladd/dart/bind_as_number/web/out/bind_as_number.dart:47:18)
Thanks for the report on this,
|Meow||1/21/13 10:54 PM||<This message has been deleted.>|