Can I use ngx-bootstrap sortable component with formArray?

Viewed 392

When I try to use ngx-bootstrap sortable component with formArray I faced a lot of errors when I tried to mix usage of reactive forms directives and bs-sortable component.

<ng-template #imageTemplate let-item="item" let-index="index"><span>{{index}}: <pre>{{item | json}}</pre></span></ng-template>
<bs-sortable
    [(ngModel)]="imagesFormArray.controls"
    [itemTemplate]="imageTemplate"
    itemClass="sortable-item"
    itemActiveClass="sortable-item-active"
    placeholderItem="Drag here"
    placeholderClass="placeholderStyle"
    wrapperClass="sortable-wrapper"
></bs-sortable>

The error I get in the console is

ERROR Error: 
  ngModel cannot be used to register form controls with a parent formGroup directive.  Try using
  formGroup's partner directive "formControlName" instead.`

If I change ngModel to formArrayName there is no error, but nothing is outputed at all.

The official documentation has only ngModel approach, but this doesn't work fro me

1 Answers
Related