Angular Table with Examples

Directive ng-repeat is used to draw table easily.
e.g.

<html>
<head>
<title>Angular JS Table</title>
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<style>
table, th , td {
border: 1px solid black;
padding: 4px;
}
</style>
</head>
<body>
<h2>AngularJS Tables</h2>
<div ng-app = "details" ng-controller = "studentController">
<table>
<tr>
<th>Subject Name</th>
<th>Marks</th>
</tr>
<tr ng-repeat = "subject in student.subjects">
<td ng-if="$odd" style="background-color:#ff6600">{{ subject.name }}</td>
<td ng-if="$even">{{ subject.name }}</td>
<td ng-if="$odd" style="background-color:#ff6600">{{ subject.marks }}</td>
<td ng-if="$even">{{ subject.marks }}</td>
</tr>
</table>
</td>
</div>
<script>
var details= angular.module("details", []);
details.controller('studentController', function($scope) {
$scope.student = {
subjects:[
{name:'English',marks:85},
{name:'Math',marks:90},
{name:'Physics',marks:80},
{name:'Chemistry',marks:75}
]
};
});
</script>
</body>
</html>

Output

Watch this Full Stack Web Development Course video:

Angular Tables

output7

Preparing for a Job Interview? Check out our blog on Angular Interview Questions!

Course Schedule

Name Date Details
Web Development Courses 30 Mar 2024(Sat-Sun) Weekend Batch
View Details
Web Development Courses 06 Apr 2024(Sat-Sun) Weekend Batch
View Details
Web Development Courses 13 Apr 2024(Sat-Sun) Weekend Batch
View Details

Find Best AngularJS Training in Other Regions

Bangalore Hyderabad Chennai Mumbai