Angular uiRouter 解决异常

Angular uiRouter Resolve exception

为什么在使用 $httpBackend

时出现以下错误 Angular uiRoute

这是我受到攻击的模拟服务:

    $httpBackend.whenGET(editingRegex).respond(function (method, url) {

        var parameters = url.split('/');
        var length = parameters.length;
        var id = parseInt(parameters[length - 1]);

        var product = id > 0 ? products.filter(function (elem) {
            if (elem.productId === id) {
                return elem
            }
        }) : {'productId': 0};

        return [200, product, {}]
    });

这是我的ui路线代码

$stateProvider.state('productDetail', {
                url: '/products/:productId',
                templateUrl: 'app/products/productDetail.html',
                controller: 'ProductDetailController as vm',
                resolve: {
                    productResource: 'productResource',
                    product: function (productResource, $stateParams) {
                        var productId = $stateParams.productId;
                        return productResource.get({productId: productId}).$promise;
                    }
                }
            });

这是我得到的异常:

productResource 仅此而已

function productResource($resource) {
            return $resource('/api/products/:productId');
 };

Error: [$resource:badcfg] Error in resource configuration for action get. Expected response to contain an object but got an array (Request: GET /api/products/3)

.filters() 发回数组而不是对象。有我的违规行为!