0

I have the following code:

angular.module('admin')

    .factory('gridService',

    ['$resource', 'gridSelectService', 'localStorageService',

    function ($resource, gridSelectService, localStorageService) {

        var factory = {
            gridSetup: function ($scope) {            
                $scope.editRow = function (row, entityType) {             
                    window.setTimeout(function () {
                        window.setInterval(function () {
                            submitItem($scope, $scope.modal.data);
                        }, 1 * 60 * 1000);
                        submitItem($scope, $scope.modal.data);
                    }, 1 * 60 * 1000);
                }          
            submitItem: function ($scope, formData) {

            }
         }
    }

I want to call the submitItem function from inside of the window.setTimeout and the setInterval but it does not recognize the function. How can I call it ? I tried putting gridService.submitItem but that does not work either.

4

1 回答 1

2

您应该只尝试“factory.submitItem”而不是“submitItem”,它应该可以工作。

angular.module('admin')

    .factory('gridService',

    ['$resource', 'gridSelectService', 'localStorageService',

    function ($resource, gridSelectService, localStorageService) {

        var factory = {
            gridSetup: function ($scope) {            
                $scope.editRow = function (row, entityType) {             
                    window.setTimeout(function () {
                        window.setInterval(function () {
                            factory.submitItem($scope, $scope.modal.data);
                        }, 1 * 60 * 1000);
                        factory.submitItem($scope, $scope.modal.data);
                    }, 1 * 60 * 1000);
                }          
            submitItem: function ($scope, formData) {

            }
         }
    }
于 2013-10-23T06:09:02.177 回答