Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Japanese characters are not bound to angular formControl

Create simple angular project with input control
Typed Japanese characters are not bound to input control

<input type="text" [(ngModel)]="title" (input)="articleNameEntered()"/>
 title = '';
  articleNameEntered() {
    console.log('title', this.title);
  }

**# **expected result ****
japnese character should print in console

try following approach

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

use keyup event for hostlistner

still getting english character in event properties

>Solution :

This could be due to the way input events are handled with Japanese Input Method Editors (IMEs). You could use event to get the latest updated value of title.

<input type="text" (input)="onInputChange($event)">

Ts

onInputChange(event: Event): void {
   const inputElement = event.target as HTMLInputElement;
   const inputValue = inputElement.value;
   console.log(inputValue);
}

BTW, the general way to watch a model change should be like this sample:

HTML:

<input type="text" [(ngModel)]="title" (input)="articleNameEntered($event)" />

TS:

  private _title: string = '';

  get title(): string {
    return this._title;
  }

  set title(value: string) {
    this._title = value;
    console.log('set title updated:', value);
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading