简体   繁体   中英

reactive forms angular form group

Why I can't write into the input before the set value?

html

<form action="" [formGroup]="titleForm">
    <input class="note-title" type="text" formControlName="title">
</form>

typescript

  titleForm : FormGroup = new FormGroup(
    {'title':new FormControl}
  );

    this.titleForm.patchValue({
      title:"hello"
    });
  }

the input value is successfully changed but I can't write into the input

rewrite formGroup to this

  titleForm : FormGroup = new FormGroup({
      title: new FormControl('')
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM