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
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
@Arter you can comment here to ask anything if you want to clarify the code..
@Alter Did this help you?
edited my link, now you can see
i have coded for two controls. Input and Select, you need to code the same logic for others..
ok, the problem is [(ngModel)]="val" in mat-checkbox you can not assign same object to multiple controls. in your situation all three checkboxes have same reference. so, when you change one it applied to all. you need to remove this [(ngModel)]="val" and try diffrent logic. i am in office right now.. can't spent time on this :-(