Made such a factory

//Factories Versions = app.factory('Versions', function ($resource) { return $resource('http://webfather.ru:3000/api/links/', { domainid : '@domainid' }); }) 

Trying to use it in the controller.

 //Controllers app.controller('multiCtrl', ['$scope', function ($scope) { $scope.Versions = Versions.query({domainid : '56fa4eb4a93200ca38f4be8a'}); alert($scope.Versions); }]); 

And I get a TypeError error : Versions.query is not a function

what am i doing wrong?

  • 2
    Possible duplicate question: Angular.js api Requests - D-side
  • @ d-side, until at least until blue in the face minus, there is no answer in that topic - Sdafs Fasafs
  • one
    This means that the previous question was asked badly and should be edited, not duplicated. Your question is, what does not suit you the answer from there, you did not say. - D-side
  • @ d-side, this is a completely different question, here I want to find out why the error is in my code, if you are too lazy to read the entire text, do not write anything at all - Sdafs Fasafs
  • one
    The question follows from it: “How to send get, put, post, delete requests?”, Only this solution does not use any of the options described there. Therefore, the mark of duplication that you are making a request is completely wrong and you need to look at the answer to that question, because it solves the same problem. That's all I wanted to say. - D-side

1 answer 1

The error is that all the methods from the angular.module module return the module object in fact to itself.

Therefore, the code in question is fundamentally wrong.

To use the created factory, you need to add it to the controller dependencies (list of parameters)

 app.controller('multiCtrl', ['$scope','Versions', function ($scope, Versions) { 
  • Well, finally, the normal answer, and not vicious quibbles) Thank you very much, I watched video tutorials in English (not knowing it), about the factories there are no words at all, therefore I have such a crap. In general, would you be able to advise me on certain issues for a fee? - Sdafs Fasafs
  • so?) work? - Sdafs Fasafs
  • @SdafsFasafs, what happens? - Grundy
  • ^ paid consultations? - Sdafs Fasafs
  • @SdafsFasafs, :-D are you not satisfied with the question-answer format? :) - Grundy