0

I am trying to get data's leave details from server. When I click or reload the link (http://localhost/portal/getleaves) api request send two times in firebug.

Sample code attached here:

    $http.get('/portal/api/leave/'+id).
    success(function(data) {
        var data = data.result;
        $scope.tableParams = new ngTableParams({
            page: 1,            // show first page
            count: 10,           // count per page
            sorting: {
                name: 'asc'     // initial sorting
            }
        }, {
            total: data.length, // length of data
            getData: function($defer, params) {
              $defer.resolve(data);
            }
        });
    });

Thanks.

Deepak raj
  • 269
  • 1
  • 5
  • 19
  • I also faced this issue before. Please add from where you are calling this & make sure controller should execute only once(whether from state or html - ngController). –  May 22 '15 at 04:11

1 Answers1

1

It's probably one of the following:

1) Your entire controller is being executed twice.

2) You aren't actually sending out 2 GET requests. If you are doing CORS requests an OPTIONS request will be sent before the GET request is sent.

Andy Gaskell
  • 31,495
  • 6
  • 74
  • 83