Hi all,
I have an ion-input and want to have a common commenting feature as:
- user can input any text
- user hits enter key to fire comments out
- save text to db table and clean the input text field (to-be-implemented)
- the ion-input is unfocused
However, I didnt figure out how to do #3 above.
I have tried event.blur();
or this.textInput.nativeElement.blur();
but it seems neither works.
Please help.
commentHandler(event) {
const keyCode = event.keyCode;
if (keyCode === 13 && this.commentText != "") {
this.logger.info("enter hit");
event.blur();
// this.textInput.nativeElement.blur();
}
}
<ion-item>
<ion-label floating>Add comment, then hit enter</ion-label>
<ion-input #commentInput type="text" (keypress)="commentHandler($event)" ngModel="commentText"></ion-input>
</ion-item>