0

我想让这个https://stackblitz.com/edit/angular-dynamic-survey-creation-golkhg可拖动并保存到 json 文件,所以我可以查看数据,我使用了 angular cdk 但我我被困在这个函数中

onDrop(event: CdkDragDrop<string[]>) {
    moveItemInArray(this.items, event.previousIndex, event.currentIndex);
  }

我找不到要替换的变量this.items,有人可以帮我吗?当然我想将数据存储到 json 文件

4

1 回答 1

1

为此,您必须将您的 cdk 版本升级到 7.3.7,因为该功能已在该版本中发布。

之后,在您的问题中this.items需要替换为

this.surveyForm.get('surveyQuestions')['controls']

那么这个函数将如下所示:

onDrop(event: CdkDragDrop<string[]>) {
    moveItemInArray(this.surveyForm.get('surveyQuestions')['controls'], event.previousIndex, event.currentIndex);
}
于 2020-04-13T04:25:59.657 回答