Warm tip: This article is reproduced from stackoverflow.com, please click
angular typescript

Get json data from drag and drop components

发布于 2020-03-29 21:03:46

how to get data from *ngFor loop, where I call data from another component.

Take a look at a working example.

I need to create JSON from selected forms controls and values in DROP place, JSONexample

questions = [{
    type: "INPUT",
    value: "test"
}, {
    type: "SELECT_BOX",
    selectedValue: "select option 1",
    avaliableOptions: ["select option 1", "select option 2", "select option 3"]
}]

Sry, if JSON format is not ok, this is onl yfor example

in component cdk-drag-drop-connected-sorting-example I want data from FORM div.... user create custom questions, and on save I need to store selected questions, selected answer and also, all options (in the select box, checkbox...., because in future, the user will add manually all options in this questions

Questioner
Arter
Viewed
15
Zulqarnain Jalil 2020-02-02 07:41

I have modified your code for two controls, you can add more as your requirement. I have used EventEmitter() to get changed values of control as given below

@Output() valueChange = new EventEmitter();

please click here to view all code.

you will get all of your items in formitems array