title: AngularJS, creating a resource hash
body: <p>Trying to take a url and in an AngularJS controller redirect that request to the best place to get the json data. The VideoSearchCtrl is bound to the search form. The url generated is correct for the template so I'm using the controller to redirect it to the place for the json data. </p>
  
  <pre><code>GuideControllers.controller('VideoSearchCtrl', ['$scope', 'VideoSearch',
      function($scope, VideoSearch) {
          var pattern = new RegExp(".*/search\\?=(.*)");
          var params = pattern.exec( document.URL )[1];//redirect to videos to execute the search for the data
          $scope.videos = VideoSearch.query({ resource: "videos", action: "search", q: params });
      }
  ]);
  </code></pre>
  
  <p>This sends /videos/search?q=xyz in to the query. The factory creates the resource: </p>
  
  <pre><code>var VideoSearchServices = angular.module('VideoSearchServices', ['ngResource']);
  
  VideoSearchServices.factory('VideoSearch', ['$resource',
      function($resource){
          return $resource("/:resource/:action:params", {resource: "@resource", action: "@action", params: "@params"}, {
              query: {
                  isArray: true,
                  method: "GET",
                  headers: {
                      "Accept": "application/json",
                      "X-Requested-With": "XMLHttpRequest"
                  }
              }
          });
      }
  ]);
  </code></pre>
  
  <p>But the server gets the url as /videos/search%fq=xyz, not /videos/search?q=xyz and therefore the "show" method is being invoked instead of a custom "search" action.  Obviously there is some escaping somewhere? Or maybe the "?" is also a special pattern the resource factory looks for? Probably obvious to someone used to AngularJS or javascript for that matter.</p>
  
  <p>I have a template for search and the json is retrieved from a different location. Both work but I can't ask for the json with the above code. </p>