作成日: 2021/10/04 最終更新日: 2021/10/07
文書種別
制限事項
発生環境
Angularでのみ発生
状況
回避方法あり
詳細
下記例のようにコントロールに同時に値を入力した場合に、textChangedイベント内で取得できるtextの値が同じ値になる場合があります。
例:1、2、3を同時に入力する
textの値
1
123(12とならない)
123
回避方法
回避方法1
asyncBindingプロパティをfalseに設定します。
<wj-combo-box #cb (textChanged)="onTextChanged(cb, $event)" [asyncBindings]="false">
</wj-combo-box>
回避方法2
ngAfterViewInit内で、textChangePCプロパティを利用して入力された順の通りに値を取得します。
ngAfterViewInit() {
this.combo.textChangePC.subscribe((text: string) => {
console.log(text, 'comboBox text textChangePC');
});
}
またテンプレートにtextChangeイベントを設定することで、textChangePCを利用する方法もあります。
<wj-combo-box (textChange)="onTextChange( $event)">
</wj-combo-box>
onTextChange(value: string) {
console.log(value, 'comboBox text');
}