Skip to content

Instantly share code, notes, and snippets.

@kelegorm
Last active August 29, 2015 14:19
Show Gist options
  • Save kelegorm/ebfa6cf4aa974f481cb5 to your computer and use it in GitHub Desktop.
Save kelegorm/ebfa6cf4aa974f481cb5 to your computer and use it in GitHub Desktop.
Numeric Input polymer component
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();
}
}
<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