title: MEANJS server controller call from Angular service
body: <p>There are three Models in the picture User, UserDetails, Order. I want to fetch userDetails based upon the userId in Order. </p>
  
  <p>Model UserDetails:  <a href="https://i.stack.imgur.com/OpqBv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OpqBv.png" alt="enter image description here"></a></p>
  
  <p>Model Order:
  <a href="https://i.stack.imgur.com/qYKTj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qYKTj.png" alt="enter image description here"></a></p>
  
  <p>I've removed few properties in the pic to make it short.</p>
  
  <p><strong>I've a remote method on server controller</strong> </p>
  
  <pre><code>exports.userdetailByUserID = function(req, res,id) {
  //var userId = new ObjectId(id);
  Userdetail.find({ user : req.params['userId'] }).exec(function(err,     userdetail) {
          if (err) console.log(err);
          if (! userdetail) return next(new Error('Failed to load Userdetail ' + id));
          req.userdetail = userdetail ;
          console.log(userdetail);
      });
  };
  </code></pre>
  
  <p><strong>server route defined as</strong> </p>
  
  <pre><code> app.route('/orders/getUserDetails/:userId').get(orders.userdetailByUserID);
  </code></pre>
  
  <p><strong>If I make a call on browser directly like this:</strong> </p>
  
  <pre><code>http://localhost:3000/orders/getuserdetails/561ac35ce8436dc41b37011d
  </code></pre>
  
  <p><strong>I get the desired output. thats the userdetails of the userId for the order. 
  But I'm not sure how to make a call from client service. 
  I'm doing something like this below:</strong></p>
  
  <pre><code>.factory('GetUserDetails', ['$resource',
      function($resource) {
      var resource;
      resource=$resource('/orders/userdetails/:userId',{userId:  '@userId'},{
          getUserDetail:{
              method:'GET',
              isArray:true
          }
      });
          return resource;
      }]);
  </code></pre>
  
  <p>and in controller : I'm calling service like :</p>
  
  <pre><code>function loadUserDetails() {
      $scope.userDetails = GetUserDetails.getUserDetail({userId :userid}).$promise.then(function(data) {
        $scope.userDetails = data;
      });
      }
  </code></pre>
  
  <p>Its not producing the desired result as this make calls to userdetails and fetch all the records but I only want a single record for the userId I input. </p>