Last active
August 29, 2015 14:19
-
-
Save kelegorm/ebfa6cf4aa974f481cb5 to your computer and use it in GitHub Desktop.
Numeric Input polymer component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:polymer/polymer.dart'; | |
@CustomTag('numeric-input') | |
class NumericInput extends PolymerElement { | |
num _value; | |
@published | |
num get value => _value; | |
set value(num newValue) { | |
if (_value != newValue) { | |
if (newValue is String) { | |
try { | |
newValue = num.parse(newValue as String); | |
} catch (e) { | |
return; | |
} | |
} | |
_value = notifyPropertyChange(#value, _value, newValue); | |
} | |
} | |
NumericInput.created() : super.created() { | |
} | |
@override | |
void attached() { | |
super.attached(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../../../../packages/polymer/polymer.html"> | |
<polymer-element name="numeric-input"> | |
<template> | |
<input flex type="number" value="{{value}}"> | |
</template> | |
<script type="application/dart" src="numeric_input.dart"></script> | |
</polymer-element> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment