Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138221

Angular: Pass input value to FormGroup

$
0
0

I have the following template:

<form [formGroup]="entryForm" (ngSubmit)="onSubmit()">
     <div class="view">
            <div class="col">
                        <mat-form-field>
                            <textarea matInput value="Test..." formControlName="firstValue"></textarea>
                        </mat-form-field>
            </div>
            <button type="submit">Submit</button>
      </div>
</form>

Component:

ngOnInit() {
 this.entryForm = new FormGroup({
   firstValue: new FormControl('')
 });
}

public onSubmit() {
  console.log(this.entryForm.value);
}

But when I click on submit, the value of firstValue appears to be empty. Even though I see it in the input form because of the value property.


Viewing all articles
Browse latest Browse all 138221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>