From 52c13156f9db76fbc9fc047ce668c777b0650a24 Mon Sep 17 00:00:00 2001 From: Daryl Fritz Date: Sun, 31 Jan 2016 23:48:22 -0500 Subject: [PATCH 1/3] Allow tokenized URL --- README.md | 2 +- angucomplete.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6bbb2bc..59fe762 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}&param2=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..1b22be3 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("title") !=-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); From c03d6e39de9d8a30b3f3be440928eb5898f59abe Mon Sep 17 00:00:00 2001 From: Daryl Fritz Date: Sun, 31 Jan 2016 23:50:04 -0500 Subject: [PATCH 2/3] Fix README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59fe762..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 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}&param2=value | +| 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 | From 8fed1e6e6764569975c608b2a39fb011a68c3b24 Mon Sep 17 00:00:00 2001 From: Daryl Fritz Date: Wed, 17 Feb 2016 20:11:33 -0500 Subject: [PATCH 3/3] Update angucomplete.js --- angucomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angucomplete.js b/angucomplete.js index 1b22be3..307e319 100644 --- a/angucomplete.js +++ b/angucomplete.js @@ -131,7 +131,7 @@ angular.module('angucomplete', [] ) } else { var remoteUrl = $scope.url + str; - if($scope.url.indexOf("title") !=-1) { + if($scope.url.indexOf("{0}") !=-1) { remoteUrl = $scope.url.replace('{0}', str); } $http.get(remoteUrl, {}).