动态表格可使用角度cdk拖放进行排序

时间:2020-09-01 23:00:59

标签: json angular angular-reactive-forms

我正在尝试创建一个Google表单克隆,这是它的样子

enter image description here

当我向下拖动第一个表格时,会发生这种情况

enter image description here

mat-select值不变,并且复选框选项不见了。对于放置功能,我有这个

  drop(event: CdkDragDrop<string[]>) {
    this.list = this.surveyForm.get("sectionQuestions")["controls"];
    console.log(this.list);
    moveItemInArray(this.list, event.previousIndex, event.currentIndex);
    this.questionFormArray.controls[event.currentIndex]['controls']['display_order']
      .setValue(event.currentIndex + 1);
    this.questionFormArray.controls.forEach((category, index) => {
      (category as FormGroup).controls['display_order'].setValue(index + 1);
    });
  }

我错过了什么吗?通过设置display_order还不够吗?任何想法都会有所帮助

0 个答案:

没有答案
相关问题