FormGroup中patchValue怎么更新值?

初始化的时候创建表单

ngOnInit() {
    this.retrieve();
    this.createForm();
  }

但是表单的值,只会获取自定义的时候的值,

// 创建表单
  createForm() {
    this.form = this.formBuilder.group({
      funcAllID: new FormControl(),
    });
    this.form.patchValue({ funcAllID: this.keys},);
  }

通过触发进行keys更新

// 点击复选框触发
  nzCheck(event: NzFormatEmitEvent): void {
    this.keys = event.keys || [];
  }

怎么样写,才能让patchValue的时候,获取最新的值

阅读 2.6k
1 个回答
// 点击复选框触发
nzCheck(event: NzFormatEmitEvent): void {
    this.form.patchValue({funcAllId:event.keys})
  }

你赋值写错地方了..

推荐问题