From f9bec4372a3faa163e95c9ddc92fbe0cb3eaf368 Mon Sep 17 00:00:00 2001 From: Theo Denovan Date: Sat, 10 Jan 2015 13:15:57 +1100 Subject: [PATCH 1/3] Updated to support triggering an autocomplete query when using the ng-model to set the textbox value. --- README.md | 4 ++++ src/ngAutocomplete.js | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2298e11..65d7c2c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# tdenovan Changes + +Updated to support triggering an autocomplete query when using the ng-model to set the textbox value. + # ng-Autocomplete A simple directive for adding google places autocomplete to a textbox element. diff --git a/src/ngAutocomplete.js b/src/ngAutocomplete.js index 3b0b33c..ba8dd7c 100644 --- a/src/ngAutocomplete.js +++ b/src/ngAutocomplete.js @@ -42,6 +42,7 @@ angular.module( "ngAutocomplete", []) //options for autocomplete var opts var watchEnter = false + //convert options provided to opts var initOpts = function() { @@ -83,6 +84,7 @@ angular.module( "ngAutocomplete", []) if (scope.gPlace == undefined) { scope.gPlace = new google.maps.places.Autocomplete(element[0], {}); } + google.maps.event.addListener(scope.gPlace, 'place_changed', function() { var result = scope.gPlace.getPlace(); if (result !== undefined) { @@ -138,7 +140,7 @@ angular.module( "ngAutocomplete", []) element.val(detailsResult.formatted_address); element.unbind('focusout') }) - + }); } } @@ -152,6 +154,12 @@ angular.module( "ngAutocomplete", []) var location = controller.$viewValue; element.val(location); }; + + // Trigger query for any address present on the model when the autocomplete is initialized + if (scope.ngModel) { + var result = { name: scope.ngModel }; + getPlace(result); + } //watch options provided to directive scope.watchOptions = function () { From ba927092c5bac7c9307c1398bb8c90a45abd9ff2 Mon Sep 17 00:00:00 2001 From: Theo Denovan Date: Sat, 10 Jan 2015 13:21:44 +1100 Subject: [PATCH 2/3] Updated to support triggering an autocomplete query when using the ng-model to set the textbox value. --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 65d7c2c..2298e11 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -# tdenovan Changes - -Updated to support triggering an autocomplete query when using the ng-model to set the textbox value. - # ng-Autocomplete A simple directive for adding google places autocomplete to a textbox element. From 29d7d45e7940cff0d6a3e6503703046779ae6e03 Mon Sep 17 00:00:00 2001 From: Theo Denovan Date: Sat, 10 Jan 2015 13:29:06 +1100 Subject: [PATCH 3/3] version bump --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 8b61562..f89a284 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ngAutocomplete", - "version": "1.0.0", + "version": "1.0.1", "main": "src/ngAutocomplete.js", "dependencies": { "angular": ">=1.2.0"