Agata
Agata

Reputation: 362

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

Upvotes: 0

Views: 51

Answers (1)

Alireza Ebrahimkhani
Alireza Ebrahimkhani

Reputation: 551

rewrite formGroup to this

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

Upvotes: 1

Related Questions