I have a dynamic size of items. For every item I want to generate a checkbox. I thought the best approach for that is to use the FormArray.
But I cannot set any additional property to specifiy the label for the dynamic checkboxes.
items: Array<string> = ['Banana', 'Apple', 'Beer', 'Water'];
let checkboxArray = new FormArray([]);
this.items.forEach(item => {
let formControl = new FormControl(true);
checkboxArray.push(formControl);
})
But as we see here, i can only specifiy the value for the checkbox in the formControl, but cannot set any additional info about the label.
A working plunkr is here: http://plnkr.co/edit/ODe5QSOEvQsQiuBzs56o?p=preview