How to unfocus ionic-input when enter is hit


Hi all,

I have an ion-input and want to have a common commenting feature as:

  1. user can input any text
  2. user hits enter key to fire comments out
  3. save text to db table and clean the input text field (to-be-implemented)
  4. 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 != "") {"enter hit");
      // this.textInput.nativeElement.blur();
    <ion-label floating>Add comment, then hit enter</ion-label>
    <ion-input #commentInput type="text" (keypress)="commentHandler($event)" ngModel="commentText"></ion-input>