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.

3
  • have you tried 'factory.submitItem' instead of 'submitItem' only? Commented Oct 23, 2013 at 5:48
  • yes that works ! Can you put as an answer so I can accept. Commented Oct 23, 2013 at 5:59
  • I have added an answer Commented Oct 23, 2013 at 6:09

1 Answer 1

2

You should try 'factory.submitItem' instead of 'submitItem' only and it should work.

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) {

            }
         }
    }
Sign up to request clarification or add additional context in comments.

Comments