<button (click)="addTextArea()">Add Comment</button>
<div formArrayName="comments">
<div *ngFor="let comment of commentsArray.controls; let i=index>
<textarea>{{comment.value..}}</textarea>
</div>
</div>
addTextArea() {
const fc1 = this.fb.control('', [Validators.required]);
const fc2 = this.fb.control('', [Validators.required]);
this.commentsArray.insert(0,
this.fb.group({
code: fc1,
value:fc2
}
}
What I want to do is set focus on the newly added textarea. How would I do that. Thanks