Here's my html:
<polymer-element name="my-textarea">
<template>
<link rel="stylesheet" href="my_textarea.css">
<textarea value="{{val}}"></textarea>
<p>Val is: {{val}}</p>
</template>
<script type="application/dart" src="my_textarea.dart"></script>
</polymer-element>
Here's my dart:
@CustomTag('my-textarea')
class MyTextarea extends PolymerElement {
@observable var val = "Hello, World";
MyTextarea.created() : super.created() {}
valChanged(oldValue, newValue) {
print("okay!");
}
}
Instead of printing "okay!" when the value of the textarea changes, I would like to print the selectionStart. This is a property of the HTML element, so I need a reference to it. How can I get that inside the valChanged function?
If you add an ID to the
<textarea>
, you can access it from within your class like so:$['my-textarea']
With that reference, you can access any textarea property you want.