Angular formarray checkboxes

前端 未结 2 384
栀梦
栀梦 2020-12-22 03:24

what is the proper way to setup this code. I want to user select checkbox and value of that checkbox to be pushed into FormArray now I get [true,false,fal

2条回答
  •  暖寄归人
    2020-12-22 03:54

    You can merge value received from formArray with data:

    newCheckboxValue.map((value, index) => value ? data[index] : null).filter(value => value)
    

    Transforming bool array to array of labels/null, then removing null

提交回复
热议问题