搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
AngularJS 教程
AngularJS 基础教程
源代码
清空
点击运行
<html> <head> <title>Angular JS Includes</title> <style> table, th , td { border: 1px solid grey; border-collapse: collapse; padding: 5px; } table tr:nth-child(odd) { background-color: #f2f2f2; } table tr:nth-child(even) { background-color: #ffffff; } </style> </head> <body> <h2>AngularJS-Ajax使用示例</h2> <div ng-app = "" ng-controller = "studentController"> <table> <tr> <th>Name</th> <th>Roll No</th> <th>Percentage</th> </tr> <tr ng-repeat = "student in students"> <td>{{ student.Name }}</td> <td>{{ student.RollNo }}</td> <td>{{ student.Percentage }}</td> </tr> </table> </div> <script> function studentController($scope,$http) { var url = "/run/angularjs/data.txt"; $http.get(url).then( function(response) { $scope.students = response.data; }); } </script> <script src = "https://cdn.staticfile.org/angular.js/1.2.15/angular.min.js"> </script> </body> </html>
运行结果