Simple example of ng-repeat in Angularjs
The first example: the easiest example of using ng-repeat
<html ng-app="myApp"> <head> <title>angularjs-demo</title> <script type="text/javascript" src="" charset="utf-8"></script> </head> <body ng-controller="ctrl"> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <th>Student ID</th> <th>Name</th> <th>Fraction</th> </tr> <tr ng-repeat="item in items"> <td>{{}}</td> <td>{{}}</td> <td>{{}}</td> </tr> </table> <script> var app = ('myApp',[]); ("ctrl",function($scope,$location){ $ = getStu(); }); function getStu() { return [{id:1010,name:'Zhang San',score:50},{id:1011,name:'Li Si',score:60},{id:1012,name:'Wang Wu',score:80}]; } </script> </body> </html>
Second example: Add filter conditions
<html ng-app="myApp"> <head> <title>angularjs-demo</title> <script type="text/javascript" src="" charset="utf-8"></script> </head> <body ng-controller="ctrl"> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <th>Student ID</th> <th>Name</th> <th>Fraction</th> </tr> <tr ng-repeat="item in items | filter:fscore"> <td>{{}}</td> <td>{{}}</td> <td>{{}}</td> </tr> </table> <script> var app = ('myApp',[]); ("ctrl",function($scope,$location){ $ = getStu(); $ = function(e) { return >=60; } }); function getStu() { return [{id:1010,name:'Zhang San',score:50},{id:1011,name:'Li Si',score:60},{id:1012,name:'Wang Wu',score:80}]; } </script> </body> </html>
The above is an example of the use of ng-repent in AngularJs. If you have any questions, please leave a message or go to the community of this site to communicate and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!