I have an HTML file using a <textarea>
whose input I want to acquire using an Angular controller. Relevant HTML code is as follows:
<div class="list">
<textarea
placeholder="Comments"
id="feedback"
ng-model="feedbackInput">
</textarea>
</div>
Here is the relevant code for my Javascript controller, which I feel like is on the right track, but produces the output:
$scope.finishSummary = function(){
$scope.feedbackInput = "";
console.log( "Feedback text = " + JSON.stringify($scope.feedbackInput) );
}
which produces the output:
Feedback text= ""
I use a "console.log()" simply for debugging purposes, but I want to be able to see the actual input value from the <textarea>
. I'm relatively new to coding in HTML and especially with using Angular, so excuse my inexperience with the matter. In the end I just want to check to see if there is no text in the <textarea>
. Any suggestions with how to do this so I can inject the data input from <textarea>
into Angular? Thanks!
You are resetting the value "", just remove that line,
$scope.finishSummary = function(){
console.log( "Feedback text = " + JSON.stringify($scope.feedbackInput) );
}
Also you are not calling the finishSummary()
anywhere in your code, you can call it in ng-blur to see the changes of the variable
<textarea
placeholder="Comments"
id="feedback"
ng-blur="finishSummary()"
ng-model="feedbackInput">
</textarea>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.