how to dynamically Add and Delete rows dynamically using angularjs?

Today, We want to share with you add and delete rows dynamically using angularjs.In this post we will show you add/remove input fields dynamically with angularjs, hear for Angularjs create table with add/delete row, from ng-repeat in object of objects we will give you demo and example for implement.In this post, we will learn about Add or Remove Table Rows Dynamically in AngularJS with an example.

add, edit delete table row using angularjs



<body ng-app="myapp" ng-controller="ListController">     
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <form ng-submit="addNew()">
                            <table class="table table-striped table-bordered">
                                        <th><input type="checkbox" ng-model="selectedAll" ng-click="checkAll()" /></th>
                                        <th>Customer Firstname</th>
                                        <th>Customer Lastname</th>
                                        <th>Customer Email</th>
                                    <tr ng-repeat="customerDetail in customerDetails">
                                            <input type="checkbox" ng-model="customerDetail.selected"/></td>
                                            <input type="text" class="form-control" ng-model="customerDetail.firstnm" required/></td>
                                            <input type="text" class="form-control" ng-model="customerDetail.lastnm" required/></td>
                                            <input type="email" class="form-control" ng-model="" required/></td>

                            <div class="form-group">
                                <input ng-hide="!customerDetails.length" type="button" class="btn btn-danger pull-right" ng-click="remove()" value="Remove">
                                <input type="submit" class="btn btn-primary addnew pull-right" value="Add New">

Angularjs Code


var app = angular.module("myapp", []);
app.controller("ListController", ['$scope', function($scope) {
    $scope.customerDetails = [
            'email':'[email protected]'
            'email':'[email protected]'
            'email':'[email protected]'
        $scope.addNew = function(customerDetail){
                'firstnm': "", 
                'lastnm': "",
                'email': "",
        $scope.remove = function(){
            var newDataList=[];
            $scope.selectedAll = false;
            angular.forEach($scope.customerDetails, function(selected){
            $scope.customerDetails = newDataList;
    $scope.checkAll = function () {
        if (!$scope.selectedAll) {
            $scope.selectedAll = true;
        } else {
            $scope.selectedAll = false;
        angular.forEach($scope.customerDetails, function(customerDetail) {
            customerDetail.selected = $scope.selectedAll;

CSS code


    margin-right: 10px;
  margin: 20px 0;

Demo with Source code Add/Delete rows in table dynamically using Angular

Also Read This πŸ‘‰   Laravel 6 Hello world example - PHP framework

I hope you get an idea about Add/Delete rows in table dynamically.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.