How do I assign all selected measures to my "answers" object?
The selected measures are:
get selectedMeasures() {
const items = this.measureItems.filter((item: any) => item.selected);
return items.length ? JSON.stringify(items.map(item => ({value: item.value}))) : '';
}
This is the output of selected measures:
console.log('selectedMeasures: '+ this.selectedMeasures);
Output:
selectedMeasures: [{"value":"Average"},{"value":"Last"}]
I have an exported interface called answers.ts:
export interface Answers {
id?: number;
f01: string;
f02: string;
cb1: string;
}
In my main .ts file, I have:
answers: Answers = {
id: undefined,
f01: '',
f02: '',
cb1: this.selectedMeasures
};
However, there is nothing in cb1.
f01 and f02 work fine. For example, for f01:
<input id="f01" [(ngModel)]="answers.f01" type="text" class="form-control cc-exp">
I did the same for my multiselect component:
<ngx-dropdown-list [items]="measureItems" id="cb1" [(ngModel)]="answers.cb1" [multiSelection]="true" [placeHolder]="'Measures'"></ngx-dropdown-list>
How can I correctly insert the output into cb1?