Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can I two way binding a properties type of 'Number' to attribute? #1856

Closed
w88975 opened this issue Jun 12, 2015 · 2 comments
Closed

can I two way binding a properties type of 'Number' to attribute? #1856

w88975 opened this issue Jun 12, 2015 · 2 comments

Comments

@w88975
Copy link

w88975 commented Jun 12, 2015

I define a properties, type of 'Number':

properties: {
            inputValue: {
            type: Number,
            notify: true,
            value: 0,
            observer: '_inputValueChanged',
        },
}

I set the element Attribute with this properties:

<input type="number" value="{{inputValue::input}}">

I input some number in this element,I got this inputValue, output a 'string' type value?

how can I get a 'number' type value, and how can I set the tow way binding value type of 'number'?

thanks!

@ghost
Copy link

ghost commented Jun 12, 2015

You need to compute the value, converting it to a Number type.

Number(variable);

I recommend not using parseInt as it causes a Maximum call stack size exceeded error, probably due to some bug in the way Polymer implemented the computation.

You also forgot this: 👎 inputValue::input within curly braces 👍 {{inputValue::input}} , I guess, as you said you know the type of your input value, you didn't write that in your issue.
Here is a working example: http://jsbin.com/cowoha/1/edit

@w88975
Copy link
Author

w88975 commented Jun 12, 2015

@peduxe

I made a mistake on this issue, but my code are right 😓.

thanks for you .

this computed are pretty good.

@sjmiles sjmiles changed the title can I tow way binding a properties type of 'Number' to attribute? can I two way binding a properties type of 'Number' to attribute? Jun 12, 2015
@w88975 w88975 closed this as completed Jun 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant