I must add 3 textarea and button which allow add next textarea and be able to save the text entered in the textarea I try do it like this:
<form>
<div class="form-group">
<div class="row">
<div class="col-md-4" *ngFor="let t of textarea; let in=index">
<textarea class="form-control" id="" rows="5" [(ngModel)]="textarea[in]" name="something" class="form-control" placeholder="Type here to add..."></textarea>
</div>
<button (click)="add()">Add input</button>
</div>
</div>
</form>
ts
export class TextareaComponent {
textarea: any[]
constructor() {
this.textarea = ['', '', ''];
}
add() {
this.textarea.push('');
}
}
But it's strange effect when I try add something to first textarea... https://stackblitz.com/edit/angular-bjungk?file=src%2Fapp%2Fapp.component.html
I want to be able to type something to each textarea, now when I try type something to first textarea, the same is display in second and third textarea.
reactive formgive more advantages in angular. - Shashikant Devani