angularJs isArray:false或true

时间:2015-02-11 00:01:02

标签: java javascript angularjs rest spring-mvc

我尝试通过Spring rest和AngularJS从数据库中获取数据,但我得到了这个 错误:当make isArray时:true

"Error: [$resource:badcfg] Error in resource configuration. Expected
  response to contain an array but got an object

并尝试通过make

解决此错误
 'query': { method: 'GET', isArray: false}

我收到此错误

[$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.2.26/$rootScope/inprog?p0=%24digest

这是我的代码

@RequestMapping(value = "/rest/assets",
        method = RequestMethod.GET,
        produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<Asset> getAll() {
    log.debug("REST request to get all Assets");
    List<Asset> assets=assetService.getAllOrderByIdDesc();
    return assetService.getAllOrderByIdDesc();
}

rout.js

 adapApp
   .config(function ($routeProvider, $httpProvider, $translateProvider
       , USER_ROLES) {
        $routeProvider
            .when('/asset', {
                templateUrl: 'views/assets.html',
                controller: 'AssetController',
                resolve:{
                    resolvedAsset: ['Asset', function (Asset) {
                        return Asset.query().$promise;
                    }]
                },
                access: {
                    authorizedRoles: [USER_ROLES.all]
                }
            })
    }); 

service.js

adapApp.factory('Asset', function ($resource) {
    return $resource('app/rest/assets/:id', {}, {
        'query': { method: 'GET', isArray: false},
        'get': { method: 'GET'}
    });
 });

控制器

adapApp.controller('AssetController', function ($scope, resolvedAsset
      , Asset ) {
$scope.assets = resolvedAsset;
});

html page

<tr ng-repeat="asset in assets">
                    <td>{{asset.id}}</td>
                    <td>{{asset.assetName}}</td>
                    <td>{{asset.locations[0]}}</td>
                    <td>{{asset.airport.iatacode}}</td>
                    <td>{{asset.lastupdateUserid}}</td>
                    <td>{{asset.lastupdateDateTime}}</td>
                    <td>{{asset.domainName}}</td>
                    <td>
 <tr>

0 个答案:

没有答案