【发布时间】:2016-08-22 23:49:49
【问题描述】:
我对 ngResource 有疑问。 这是我的.factory
app.factory('sveKlupeServiceFactory', ['$resource',
function($resource){
return $resource('myURL/to/json', {},{
// { method: 'getKlupe', q: '*' },
query: { method: 'GET', params:{klupaId:'klupe'}, isArray:true}
});
这是我的控制器
app.controller('klupeController', ['$scope', 'sveKlupeServiceFactory', function ($scope,sveKlupeServiceFactory){
$scope.klupe = sveKlupeServiceFactory.query();
}]);
在 html 我有这个
<tr ng-repeat="klupa in klupe">
<td>{{klupa.serial_number}}</td>
<td>{{klupa.location_id}}</td>
<td>{{klupa.type}}</td>
<td>{{klupa.last_report_dt}}</td></tr>
问题: 在我的浏览器中,我有表格,但有空行。没有任何错误。
在我的应用中
var app = angular.module('App', [
'ngRoute',
'ngResource']);
有人可以帮我提些建议吗?
谢谢。
【问题讨论】:
-
控制台有错误吗?
-
您好,没有任何错误
-
在你的控制器(或console.log)中放置一个断点并验证$scope.klupe是否包含数据
-
在控制台日志中他们给了我 d {$promise: d, $resolved: false}$promise: d$resolved: truesmart_benches: Array[7]__proto__: Object controllers.js:26 d {$承诺:d,$resolved:假}
标签: angularjs factory ngresource