Home  /  Coding   /  How To Add Dynamic Input Fields In Angular | AV Coding

How To Add Dynamic Input Fields In Angular | AV Coding

Hey guys welcome to AV Coding

Today we will learn how to add dynamic input fields in angular simple and easy.

We will be using stackbliz for live preview and you can find the preview link below

Preview Link :-

The complete code is explained in the video below and the source code is provided below.


import { Component, OnInit } from '@angular/core';

  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
export class AppComponent implements OnInit {
  name = 'Dynamic Add Fields';
  values = [];
  ngOnInit() {


    this.values.push({value: ""});


<h2>{{ name }}</h2>
<div *ngFor="let value of values; let i = index"> 
  <input type="text" [(ngModel)]="value.value" #name="ngModel" name="value{{i}}">
  <button (click)="removevalue(i)">Remove</button>
<button (click)="addvalue()">ADD</button>

<div *ngFor="let value of values;">
  {{ value.value }}

Hope You Liked This Blog. Share, Comment, Subscribe And Press The Bell Icon In The Bottom Right Side For More Code Feeds