AngularJS无法获取超过4条记录

时间:2016-02-18 11:11:29

标签: angularjs

以下代码用于AngularJS代码从.txt文件读取数据并在网页上回显。它适用于.txt文件中输入的记录,但是当增加4以上的记录数时,代码无法正常工作。可能有什么不对?

的index.html

<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 Sample Application</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="data.txt";
   $http.get(url).success( function(response) {
                           $scope.students = response;
                        });
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</body>

DATA.TXT

[
{
"Name" : "Collin James",
"RollNo" : 101,
"Percentage" : "81.5%"
},
{
"Name" : "Michael Ross",
"RollNo" : 201,
"Percentage" : "70%"
},
{
"Name" : "Robert Flare",
"RollNo" : 191,
"Percentage" : "75%"
},
{
"Name" : "Julian Joe",
"RollNo" : 111,
"Percentage" : "77%"
}
]

0 个答案:

没有答案
相关问题