对我有这样的代码在我stucontrollers.j
数据未显示
/// <reference path="../angular.js" />
var stucontrollers = angular.module("stucontrollers", []);
stucontrollers.controller("GetStudentsList",
function GetStudentsList($scope, $http) {
$http({
method: 'GET',
url: '/api/students'
}).then(function(data) {
$scope.students = data;
});
});
,并在我的view
,我有这个
<div ng-app="StudentApp">
<div ng-controller="GetStudentsList">
<table>
<thead>
<tr>
<th>Id</th>
<th>FistName</th>
<th>LastName</th>
<th>Age</th>
<th>Gender </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in students">
<td>{{item.Id}}</td>
<td>{{item.FirstName}}</td>
<td>{{item.LastName}}</td>
<td>{{item.Age}}</td>
<td>{{item.Gender}}</td>
</tr>
</tbody>
</table>
</div>
</div>
,在我app.js
这个是什么我有
/// <reference path="../angular.js" />
var module = angular.module("StudentApp", ["stucontrollers"]);
这是在我的StudentsController.cs
// GET: api/Students
public IQueryable<Student> GetStudents()
{
return db.Students;
}
我试图让学生进入我的观点的列表,但我只能得到它在页面检查器中未在网页上显示的响应。我究竟做错了什么。谢谢。
编辑 现在我能够在控制台中看到我的数据。但我仍然无法在我的页面中看到它。以下是我在控制台中获得的数据。
data
:
Array(2)
0
:
{Id: 1, FirstName: "Juan", LastName: "Dela Cruz", Age: 25, Gender: "Male"}
1
:
{Id: 2, FirstName: "Maria ", LastName: "Makiling", Age: 30, Gender: "Female"}
你好:d你能发布从请求你的回报? –