如何正确调用我的工厂服务?

How to call my factory service correctly?

我在尝试调用我的服务时收到 'is not a function' 错误。 NgResource 已经注入。我做错了什么?

controller.js:

app.controller('controllerA', ['$scope', 'CustomizingService', 
    function($scope, CustomizingService) {
        $scope.cust = CustomizingService.Customizing.squares({numberOf: 2, valid: true});
}]);

service.js:

(function () {

    angular.module('ST_CCG').factory('CustomizingService', ['$resource', function ($resource) {
        //var url = config.CustomizingAPI_Url + '/Customizing/:link/';
        var url = 'http://localhost:54483/BusinessService.svc/:link/';

        return {
            Customizing: $resource(url,  {
                squares: {
                    method: 'GET',
                    params: { link: 'GetSquares', numberOf: '@numberOf', valid: @valid },
                    isArray: true },
                 circles: {
                    method: 'GET',
                    params: { link: 'GetCircles',  valid: true },
                    isArray: true }
            })
        };
    }]);
})();

编辑

我正在使用 chrome 调试器并收到以下错误: TypeError: CustomizingService.Customizing.orders 不是函数

app.js:

var app = angular.module('ST_CCG', [
  'ngRoute',
  'ngResource'
])
.config(['$routeProvider', 
        function ($routeProvider) {
            $routeProvider.
                when('/menu', {
                    templateUrl: 'Modules/Menu/view.html',
                    controller: 'controllerA'
                }).
                when('/orders', {
                    templateUrl: 'Modules/Orders/view.html',
                    controller: 'controllerB'
                }).
                otherwise({
                    redirectTo: '/'
                });
        }
]);

index.html:

...
<!--MODOLE + CONTROLLER Resources-->
<script src="app.js"></script>
<script src="service.js"></script>
<script src="modules/menu/controller.js"></script>
<script src="modules/orders/controller.js"></script>
</head>

<body ng-app="ST_CCG">

<a href="#/menu">Menu</a>
<a href="#/orders">Orders</a>

<div ng-view></div>

</body>

这可能是因为您在默认参数 所在的位置传递了操作。改成

Customizing: $resource(url, {valid: true}, {
    squares: // etc

我使用 valid: true 作为默认参数,因为您似乎在两个操作中都使用了它。