AngularJs Add Table Row

AngularJs Add Table Row – It is very easy to add/append a new row in table, Unlike jQuery or other framework you don’t need to put much effort to append new row in table. Here in this tutorial we are going to explain how you can add/append a new table row in AngularJs. You can use our online editor to edit and run the code online.

AngularJs Add Table Row | Append a New Row | Example | Demo

To append/add a new row in a table you don’t need to add the tr, td html tags to add new row. You can do it very easily if you have basic knowledge of AngularJs. You have to just update the object/array used in table. Let us create a simple example to understand this functionality.

AngularJs Add Table Row : Append Table Row Example

<!DOCTYPE html>
<html lang="en">
 <script src="//"></script>
var myApp = angular.module("myApp", []);
 myApp.controller("myController", function($scope) {
 $scope.rows = ['Table Row 1', 'Table Row 2'];
 $scope.counter = 2;
 $scope.addNewRow = function() { 
	$scope.rows.push('Table Row  ' + $scope.counter );
<div ng-app="myApp">  
<div ng-controller="myController"> 
<tr><th>Sample Table</th></tr>
<tr ng-repeat="content in rows">
 <button ng-click='addNewRow()' >Add New Row</button>

Try it »

Now everything is ready just run the above example to see the demo. If you run the above example it will produce the output something like this –

AngularJs Add Table Row | Append a New Row | Example | Demo


Add Comment

📖 Read More