我有这个字段:
<form (ngSubmit)="postComment()" [formGroup]="commentForm">
<textarea formControlName="comment"></textarea>
...
我想在 div 中显示值:
<div>{{commentForm.controls.comment.???}}</div>
最佳答案
要获取控件的值,首先我们必须使用 get 方法获取控件,然后必须获取 value 属性,如下所示:
<div>{{ commentForm.get('comment').value }}</div>
关于forms - 使用formBuilder angular2获取 View 中的字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41757525/