diff --git a/README.md b/README.md index 6bbb2bc..2775c17 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ var app = angular.module('app', ["angucomplete"]); | placeholder | Placeholder text for the search field | No | Search members | | pause | The time to wait (in milliseconds) before searching when the user enters new characters | No | 400 | | selectedObject | Where to store the selected object in your model/controller (like ng-model) | Yes | myObject | -| url | The remote URL to hit to query for results in JSON. angucomplete will automatically append the search string on the end of this, so it must be a GET request | No | http://myserver.com/api/users/find?searchstr= | +| url | The remote URL to use to query for results in JSON. By default, angucomplete will automatically append the search string on the end of this value; however, use the token {1} if the search term is in the middle of the url. The URL must be a GET request | No | http://example.com/api/users/find?searchstr=

http://example.com/api/users/find?searchstr={1}¶m2=value | | datafield | The name of the field in the JSON object returned back that holds the Array of objects to be used for the autocomplete list. | No | results | | titlefield | The name of the field in the JSON objects returned back that should be used for displaying the title in the autocomplete list. Note, if you want to combine fields together, you can comma separate them here (e.g. for a first and last name combined) | Yes | firstName,lastName | | descriptionfield | The name of the field in the JSON objects returned back that should be used for displaying the description in the autocomplete list | No | twitterUsername | diff --git a/angucomplete.js b/angucomplete.js index 734e9a2..307e319 100644 --- a/angucomplete.js +++ b/angucomplete.js @@ -130,7 +130,11 @@ angular.module('angucomplete', [] ) $scope.processResults(matches, str); } else { - $http.get($scope.url + str, {}). + var remoteUrl = $scope.url + str; + if($scope.url.indexOf("{0}") !=-1) { + remoteUrl = $scope.url.replace('{0}', str); + } + $http.get(remoteUrl, {}). success(function(responseData, status, headers, config) { $scope.searching = false; $scope.processResults((($scope.dataField) ? responseData[$scope.dataField] : responseData ), str);