Skip to content

Instantly share code, notes, and snippets.

@shailen
Created September 23, 2014 04:21
Show Gist options
  • Save shailen/eb7833d1927b783efaf3 to your computer and use it in GitHub Desktop.
Save shailen/eb7833d1927b783efaf3 to your computer and use it in GitHub Desktop.
<polymer-element name="my-element">
<template>
<div on-change="{{updateSelectedColor}}">
<template repeat="{{color in colors}}">
<label>{{color}}
<input type="radio" name="colors" value="{{color}}">
</label>
</template>
</div>
<div>{{selectedColor}}</div>
</template>
<script type="application/dart" src="my_element.dart"></script>
</polymer-element>
@CustomTag('my-element')
class MyElement extends PolymerElement {
final List<String> colors = toObservable(['red', 'green', 'blue']);
@observable String selectedColor = '';
MyElement.created() : super.created();
void updateSelectedColor(Event e, Object detail, Node sender) {
selectedColor = (e.target as InputElement).value;
}
}
// This is the exception I get when I select a radio. The `value="{{color}}"` inside the `<input>` is where the problem is.
Exception: Uncaught Error: Error evaluating expression 'color': Class 'MyElement' has no instance setter 'color='.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment