Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest AngularJS行显示为空数据_Rest_Angularjs_Restangular - Fatal编程技术网

Rest AngularJS行显示为空数据

Rest AngularJS行显示为空数据,rest,angularjs,restangular,Rest,Angularjs,Restangular,我正在测试angularJS 在app.js中,我有 function ListCtrl($scope, Restangular) { Restangular.all("employee").getList().then(function(employee) { $scope.employee = employee; console.log($scope.employee.emp); }); } 在html中我有 <table class="table t

我正在测试angularJS

在app.js中,我有

function ListCtrl($scope, Restangular) {
   Restangular.all("employee").getList().then(function(employee) {
     $scope.employee = employee;
     console.log($scope.employee.emp);
   });
}
在html中我有

<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Emp No</th>
<th>Name</th>
<th><a href="#/new"><i class="icon-plus-sign"></i></a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee | filter:search | orderBy:'ename'">
<td><a href="{{employee.empno}}" target="_blank">{{employee.empno}}</a>
</td>
<td>{{employee.ename}}</td>
<td>
<a href="#/edit/{{employee.ename}}"><i class="icon-pencil"></i></a>
</td>
</tr>
</tbody>
</table>
来自chrome浏览器的控制台日志

[Object, Object, Object, Object, Object, Object, Object, Object, 
Object, Object, Object, Object, Object, Object, route: "employee",
getRestangularUrl: function, addRestangularMethod: function, one:
function, all: function…]
0: Object
empno: "7369"
ename: "SMITH"
hiredate: "1980-12-17T00:00:00+03:00"
job: "CLERK"
mgr: "7902"
sal: "800"

根据您包含的JSON,它看起来像
$scope.employee
应该包含一个名为“emp”的键,这是您打印到控制台的内容。您可能需要更改您的ng repeat来处理该问题

另外,我不熟悉你重复表达的形式。我认为它们应该遵循类似于“某物中的某物”的形式,因此在本例中,您可能希望它是employee.emp中的
雇员,而不是
雇员


从更一般的意义上讲,for Chrome对解决这类问题非常有帮助。

使用firebug或Chrome dev工具查看应用程序从服务器接收的实际数据。它看起来像你期望的吗?空行数是否与你期望的员工数相对应?@PaulSasik是的,它与我从server@VincentRamdhanie我已经在employee.emp中包含了从server.Spot on
employee接收的JSON。非常感谢。
[Object, Object, Object, Object, Object, Object, Object, Object, 
Object, Object, Object, Object, Object, Object, route: "employee",
getRestangularUrl: function, addRestangularMethod: function, one:
function, all: function…]
0: Object
empno: "7369"
ename: "SMITH"
hiredate: "1980-12-17T00:00:00+03:00"
job: "CLERK"
mgr: "7902"
sal: "800"