【发布时间】:2016-11-10 07:08:43
【问题描述】:
<div ng-controller="studentController" ng-repeat = "student in students | unique = 'RollNo' " >
<table class="profile-info">
<tr>
<th>Roll No</th>
<td>{{ student.RollNo }}</td>
</tr>
<tr>
<th>Class</th>
<td>{{ student.Class }}</td>
</tr>
<tr>
<th>Section</th>
<td>{{ student.Section }}</td>
</tr>
<tr>
<th>Sports</th>
<td>{{ student.Sports }}</td>
</tr>
<tr>
<th>other Interests</th>
<td>{{ student.otherInterests }}</td>
</tr>
</table>
</div>
<---- Angular Part---->
// Not able to Populate the Json Value using the Follwing Script //
<script>
function studentController($scope,$http) {
var url = "aboutme.json";
$http.get(url).success( function(response) {
$scope.students = response.data;
});
}
</script>
<--- JSON PART --- >
[
{
"Class" : 1,
"RollNo" : 1,
"Section" : "A",
"Sports" : "Football",
"otherInterests" : "Music",
},
{
"Class" : 12,
"RollNo" : 2,
"Section" : "B",
"Sports" : "Counter-Strike",
"otherInterests" : "Music",
}
]
【问题讨论】:
-
大师 devji 是什么错误?
-
你甚至在附近用逗号打错了:ng-repeat = "student in students | unique = "RollNo" "
-
在发布任何代码之前,您应该确保不存在语法错误。看起来你甚至没有运行它。
-
实际上我删除并尝试执行它不起作用
-
实际上我想将 Json 值填充到表中,但无法这样做。提前致谢
标签: javascript angularjs json mean-stack