Angular TextBox - Handle the Value Change Event

When a user types a value into the TextBox, this value applies when the change event is raised. If you need the value to be applied on another event, set the valueChangeEvent property.

HTML
TypeScript
  • <dx-text-box
  • valueChangeEvent="keyup">
  • </dx-text-box>
  • import { DxTextBoxModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • // ...
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxTextBoxModule
  • ],
  • // ...
  • })

To process a new TextBox value, you need to handle the value change event. If the handling function is not going to be changed during the lifetime of the UI component, assign it to the onValueChanged property when you configure the UI component.

HTML
TypeScript
  • <dx-text-box
  • [(value)]="textBoxValue"
  • (onValueChanged)="handleValueChange($event)">
  • </dx-text-box>
  • import { DxTextBoxModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • textBoxValue = "The TextBox value";
  •  
  • handleValueChange(e) {
  • const previousValue = e.previousValue;
  • const newValue = e.value;
  • // Event handling commands go here
  • }
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxTextBoxModule
  • ],
  • // ...
  • })
See Also