title: Angular Reactive form Validation for dynamic forms inside *ngFor
body: <p>I am new to angular when I was trying to put the form validation to the text field form was present inside <code>*ngFor</code> loop, So validation is working but it shows to every field but I want validation the particular field only , so please help me How to put the validation to the particular form field.</p>
  
  <pre><code>**HTML** 
  
      &lt;div class="container" *ngFor="let post of posts; let i = index"&gt;
      &lt;div class="row"&gt;
              &lt;div class="col-md-12" style="display: block; "&gt;
  
                &lt;form [formGroup]="commentForm" method="post" enctype="multipart/form-data" (ngSubmit)="comment_Submit(post.user_id, post.post_id,
                  commentForm)"&gt;
                  &lt;div class="form-group"&gt;
                    &lt;input type="text" class="form-control" name="comment{{i}}" formControlName="comment" id="comment"
                      placeholder="Enter comments" cols="40" rows="5" spellcheck="true"
                      style="width:100%; height: auto; border: 1px solid #ada5a5; border-radius: 4px; outline: none; user-select: text; white-space: pre-wrap; overflow-wrap: break-word; "
                      [ngClass]="{'form-control': true,
                    'is-invalid': !f.comment.valid,
                    'is-valid':f.comment.valid}"&gt;
                    &lt;div *ngIf="f.comment.errors?.minlength &amp;&amp; f.comment.touched" class="text-danger"&gt;Comment
                      should be at
                      least 2 characters.&lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;button type="submit" class="btn-sm btn-success" [disabled]="!commentForm.valid"&gt;Comment&lt;/button&gt;
  
                &lt;/form&gt;
              &lt;/div&gt;
            &lt;/div&gt;
      &lt;/div&gt;
  
  **TypeScript**
  export class PostsComponent implements OnInit {
  
  get f() { return this.commentForm.controls; }
  
  constructor(private userService: UserService, private formBuilder: FormBuilder,
      private alerts: AlertsService) {
     this.commentFormValidation();
  
    }
  
  commentForm: FormGroup;
    ngOnInit() {   }
  
      commentFormValidation() {
       this.commentForm = this.formBuilder.group({
        comment: [null, [Validators.required, Validators.minLength(2)]]
      });
    }
  </code></pre>