D
D
Dmitry Kuznetsov2016-04-29 18:12:03
Angular
Dmitry Kuznetsov, 2016-04-29 18:12:03

Why are there 2 requests in a row?

In the controller, I make only one request, but two occur (with the same data):

$http({
   url: 'api/players/players',
   method: 'GET'
}).success(function(data){
   $scope.players = data;
});

What's wrong? This code is not executed anywhere else.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
curator, 2016-04-29
@dima9595

Most likely, the controller is set both in $routeProvider and in the template.

$routeProvider.when('/', {
    templateUrl: 'partials/homepage.html',
    controller: 'MyController'
});

MyController will be called twice.

6
65536, 2015-05-23
@65536

the point is $(document).ready
the calendar is bound at the moment of readiness at home. if you want it to happen at some point. transfer the hanger to some method and call it both in the read and in those moments when it is still needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question