Answer the question
In order to leave comments, you need to log in
Why does $resource.get() make 2 requests?
Hello!
I wrote this service:
app.factory('Company', function($resource){
return $resource(
'/api/company/:id/',
{id : '@id'},
{update: {method: 'PUT'}}
);
});
app.controller('CompanyDetailCtrl', function($scope, Company, $routeParams){
//Делаю инициализацию $scope
$scope.company = Company.get({id: $routeParams.id}); //id = 2, 3, N
});
Answer the question
In order to leave comments, you need to log in
Topic closed. The problem is not in the resource, but in the controller. If ngRoute is already used, then the controller must be specified either in the router or in the template, and not in both places.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question