1

I use DevExtreme in my project. I would like to do two-way data binding in dx-tag-box. I use below syntax. But it throws an error, can somebody help.

<dx-tag-box [items]="sampleProducts" [(ngModel)]="[sampleProducts[0]]"></dx-tag-box>
Sergey
  • 5,396
  • 3
  • 26
  • 38
Green Computers
  • 723
  • 4
  • 14
  • 24

1 Answers1

1

In your case, I suggest you use the value option instead of ngModel:

<dx-tag-box
    [items]="simpleProducts"
    [(value)]="values"
</dx-tag-box>

Do not forget to set the values array in your component.ts file:

export class AppComponent {
    simpleProducts: string[];
    //...
    constructor(service: Service) {
        //...
        this.simpleProducts = service.getSimpleProducts();
        this.values = [this.simpleProducts[0]];
    }
}
Sergey
  • 5,396
  • 3
  • 26
  • 38