Ng-Repeat-2

 

In this example of ng-repeat directive we have an array of the students with the name of the student,roll number, class and section of the student. with the ng-repeat directive we print the student roll no, name, class and section in the table form. see the output.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="controllerName"> <table> <tr> <th>Rollno</th> <th>Name</th> <th>Class</th> <th>Section</th> </tr> <tr ng-repeat="student in students"> <td>{{student.rollno}}</td> <td>{{student.name}}</td> <td>{{student.cls}}</td> <td>{{student.section}}</td> </tr> </table> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.students = [{ rollno: '1', name: 'John', cls: '5th', section: 'A' }, { rollno: '6', name: 'Smith', cls: '4th', section: 'D' }, { rollno: '5', name: 'Allen', cls: '6th', section: 'C' }]; }]); </script> </body> </html>
Output