One of my tasks involves utilizing an ion-textarea
for users to input content, with the objective of retrieving this text upon clicking a button.
Below is the corresponding HTML code snippet:
<ion-row>
<ion-item>
<ion-textarea [(ngModel)]="myInput" (ionInput)="getItems($event)" placeholder="New Info"></ion-textarea>
</ion-item>
</ion-row>
<button ion-button class="card-button" color="secondary"
(click)="addInfo()"> <ion-icon name="add-circle" class="icona-bottone"></ion-
icon>Add Info</button>
Attempting to achieve this functionality in my .ts file, I have:
getItems(textarea) {
// storing the value of textarea in variable q
var q = textarea.srcElement.value;
this.textSearch = q;
}
addInfo(){
console.log("You wrote " + this.textSearch)
}
However, the output ends up being "You wrote undefined
". How can I effectively capture and utilize the user input as a string?