Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavarePart 6.5-ng-repeat Directives
#1
ng-Repeat Directives:

-ng-repeat directive repeat a set of html, for a given number of times.
-the set of html will be repeated once per item in the collection and the collection must be an array or an objects.
-using ngRepeat we can display one table row for each object and one table data for each object property.


Syntax:
Code:
<element ng-repeat="expression"></element>
 

Example:
Code:
<!DOCTYPE html>
<html ng-app="myApp">
<head>

    <title>ngRepeat</title>
<script src="../angular.js"></script>
<script type="text/javascript">
    var app=angular.module("myApp",[]);
    app.controller("mycontroller",function($scope){

        $scope.person=[
        {'name':"ravi",
            'mobile':"123456789"},
        {
            'name':"rahul",
            'mobile':"987654321"
        },
        {'name':"ajay",
            'mobile':"747647459"},
        {
            'name':"anant",
            'mobile':"143435985"
        },
        {'name':"sagar",
            'mobile':"478578375"},
        {
            'name':"protutr",
            'mobile':"676778598"
        }
        ]
    });

</script>
</head>
<body>
<table border="1" ng-controller="mycontroller">
<tr ng-repeat="human in person"> //here person model stored in human object
    <td>{{human.name}}</td>
    <td>{{human.mobile}}</td>
</tr>
</table>
</body>
</html>


OUTPUT:
[Image: Kjss44m.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)