I am trying to do a simple binding from an Angular2 component to the template. My template code looks like this...
<textarea class="left-side" #newLeft (keyup)="enterLeftText($event, newLeft)"></textarea>
<textarea class="right-side">{{leftText}}</textarea>
Then in my component I have the following...
enterLeftText($event, newLeft) {
this.leftText = newLeft.value;
}
The problem is that newLeft is always undefined. What am I missing?
You found an interesting bug, as it seems we cannot have an uppercase in a #id
binding.
Simply replacing newLeft
with newleft
will solve your problem:
http://plnkr.co/edit/ngqd0cUXyxsgBKOBSr9S?p=preview
So the real answer to your problem is to write #new-left
:
<textarea class="left-side" #new-left (keyup)="enterLeftText($event, newLeft)"></textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With