title: How to pass in parameters when use resource service?
body: <p>A very rookie-ish question:</p>
  
  <p>I'm trying to build resource object using factory method:</p>
  
  <pre><code>.factory('Magazines', [function ($resource) {
  
      var url = document.URL;
      var urlArray = url.split("/");
      var organId = urlArray[urlArray.length-1];
  
      return $resource('http://localhost/ci/api/magazines/:id', {
          loginID : organEntity,
          password : organCommpassword,
          id : organId
      });
    }])
  </code></pre>
  
  <p>This method is easy because all params are predefined, organEntity and organCommpassword are defined inside  tag.</p>
  
  <p>Now for a different resource object, I need to pass in parameter when the factory is called.</p>
  
  <p>I imagine the calling code of this resource object should look like:</p>
  
  <pre><code>.controller('ResrouceCtrl', function($scope, Magazines) {
        $scope.magazines = Magazines.query();
  });
  </code></pre>
  
  <p>I know query() method can add parameters: <code>Magazines.query(params, successcb, errorcb);</code></p>
  
  <p>I wonder if I just pass in parameters, can I get the parameter at the factory? How to specify such passed in parameters in the factory method?</p>
  
  <p>For example, now suppose I cannot get organId from url anymore, I need to pass it in from my controller, how to receive organId within the factory method?</p>
  
  <hr>
  
  <p>Here is my resource js:</p>
  
  <pre><code>.factory('MagComments', function ($resource) {
  
  
      return $resource('http://localhost/dooleystand/ci/api/magCommenct/:id', {
        loginID : organEntity,
        password : organCommpassword,
        id : '@magId' //pass in param using @ syntax
      });
    })
  </code></pre>
  
  <p>Here is my controller:</p>
  
  <pre><code>$scope.magComments = MagComments.query({magId : 1});
  </code></pre>
  
  <p>I tried to pass in the parameter, but it causes an error</p>