Javascript 如何使用Angular2基于默认复选框设置rest值

Javascript 如何使用Angular2基于默认复选框设置rest值,javascript,angular,Javascript,Angular,您好,我使用的是带引导的Angular8,这里我使用了反应式表单,当我选中设置默认值复选框时,那么花卉行中的值(邮件、电子、投递和收件)应该复制到其他行 如果传真号码格式不正确,如何在特定行的下方显示错误消息 Ts: checkAll(ev){ const control=this.exampleForm.get(“打印列表”); 如果(!this.all){ this.printListArray.forEach(x=>(x.value=false)); control.patchValue(

您好,我使用的是带引导的Angular8,这里我使用了反应式表单,当我选中
设置默认值
复选框时,那么
花卉
行中的值(邮件、电子、投递和收件)应该复制到其他行

如果传真号码格式不正确,如何在特定行的下方显示错误消息

Ts:

checkAll(ev){
const control=this.exampleForm.get(“打印列表”);
如果(!this.all){
this.printListArray.forEach(x=>(x.value=false));
control.patchValue(this.printListArray);
}否则{
this.printListArray.forEach(x=>(x.value=true));
control.patchValue(this.printListArray);
}
console.log(control.value);
}
isAllChecked(){
this.all=!this.all;
}

您的代码应该更像以下代码

checkAll(ev){
const control=this.exampleForm.get(“打印列表”);
console.log(this.all);
如果(全部){
这一切都是假的;
this.printListArray.forEach(x=>(x.electronics=false));
control.patchValue(this.printListArray);
}否则{
这是真的;
this.printListArray.forEach(x=>(x.electronics=true));
control.patchValue(this.printListArray);
}

}
感谢您的回复,但很抱歉我无法运行输出您说的运行输出是什么意思?尝试此链接我尝试了此链接,但我的要求不同,在第一行(花卉行),我们有邮件、电子产品、配送下拉列表、收件,当选中“默认设置”时,邮件值、电子值、配送下拉列表值是多少,Flowers行存在recepient值,应复制到所有行,例如,如果选中,则将字段值(复选框、下拉框和文本框)复制到所有其他行。再次检查链接,我已将其设置为每当单击“与第一行相同”时按钮第一行的值将应用于其余行,逻辑与复选框相同,唯一的区别是这里我更新表单本身,而不是元素数组
 checkAll(ev) {
    const control = <FormArray>this.exampleForm.get("printList");
    if (!this.all) {
      this.printListArray.forEach(x => (x.value = false));
      control.patchValue(this.printListArray);
    } else {
      this.printListArray.forEach(x => (x.value = true));
      control.patchValue(this.printListArray);
    }
    console.log(control.value);
  }

  isAllChecked() {
    this.all = !this.all;
  }