Angular Form - Update Form Data Using the API

If you need to update form data at runtime, use two-way binding to bind the formData property to a component property. Swapping the whole formData object rerenders the UI component from scratch; updating specific formData fields rerenders only the corresponding editors.

HTML
TypeScript
  • <dx-form [(formData)]="employee"></dx-form>
  • <dx-button
  • text="Update the Phone Number"
  • (onClick)="employee.phone = '+1(333) 888-7698'">
  • </dx-button>
  • import { DxFormModule, DxButtonModule } from "devextreme-angular";
  • // ...
  • export class AppComponent {
  • employee = {
  • firstName: "Joe",
  • lastName: "Heart",
  • phone: "+1(213) 555-9392"
  • }
  • }
  • @NgModule({
  • imports: [
  • // ...
  • DxFormModule,
  • DxButtonModule
  • ],
  • // ...
  • })
See Also