I am trying to get a text areas input value after a user click a button. I need the value in the .ts file.
Here is my code and attempt
<div id="notes-container">
<label>My Queries</label>
<textarea id="query" placeholder="Enter here"></textarea>
<button class="main" (click)="close()"> Back </button>
<button class="main" (click)="sendQuery($query)"> Send Query </button>
</div>
.ts file
console.log(this.query);
I currently get no value, any ideas?
You need to use reference variables like this:
<div id="notes-container">
<label>My Queries</label>
<textarea #textArea id="query" placeholder="Enter here"></textarea>
<button class="main" (click)="close()"> Back </button>
<button class="main" (click)="sendQuery(textArea.value)"> Send Query </button>
</div>
But I recommend using Reactive Forms for all forms/inputs related stuff.
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